-
Notifications
You must be signed in to change notification settings - Fork 629
chore(docs): update useUIStream usage #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,12 +30,12 @@ export default function StreamingPage() { | |
| function App() { | ||
| const { | ||
| tree, // Current UI tree state | ||
| isLoading, // True while streaming | ||
| isStreaming, // True while streaming | ||
| error, // Any error that occurred | ||
| generate, // Function to start generation | ||
| send, // Function to start generation | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch, again! however, I'm not sure what should be done here. although the function App() {
const { isLoading, generate, abort } = useUIStream({
endpoint: '/api/generate',
});
return (
<div>
<button onClick={() => generate('Create dashboard')}>
Generate
</button>
{isLoading && (
<button onClick={abort}>Cancel</button>
)}
</div>
);
} |
||
| abort, // Function to cancel streaming | ||
| } = useUIStream({ | ||
| endpoint: '/api/generate', | ||
| api: '/api/generate', | ||
| }); | ||
| }`}</Code> | ||
|
|
||
|
|
@@ -101,28 +101,28 @@ function App() { | |
| The Renderer automatically updates as the tree changes: | ||
| </p> | ||
| <Code lang="tsx">{`function App() { | ||
| const { tree, isLoading } = useUIStream({ endpoint: '/api/generate' }); | ||
| const { tree, isStreaming } = useUIStream({ api: '/api/generate' }); | ||
|
|
||
| return ( | ||
| <div> | ||
| {isLoading && <LoadingIndicator />} | ||
| {isStreaming && <LoadingIndicator />} | ||
| <Renderer tree={tree} registry={registry} /> | ||
| </div> | ||
| ); | ||
| }`}</Code> | ||
|
|
||
| <h2 className="text-xl font-semibold mt-12 mb-4">Aborting Streams</h2> | ||
| <Code lang="tsx">{`function App() { | ||
| const { isLoading, generate, abort } = useUIStream({ | ||
| endpoint: '/api/generate', | ||
| const { isStreaming, send, abort } = useUIStream({ | ||
| api: '/api/generate', | ||
| }); | ||
|
|
||
| return ( | ||
| <div> | ||
| <button onClick={() => generate('Create dashboard')}> | ||
| <button onClick={() => send('Create dashboard')}> | ||
| Generate | ||
| </button> | ||
| {isLoading && ( | ||
| {isStreaming && ( | ||
| <button onClick={abort}>Cancel</button> | ||
| )} | ||
| </div> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.