Last active
March 21, 2024 01:30
-
-
Save subtleGradient/40104417bbf7b48f060ac9197832a7e5 to your computer and use it in GitHub Desktop.
example of what a re-renderable React server component could maybe look like?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use server" | |
import { $ } from "bun" | |
export async function* CurrentServerTime() { | |
while (true) { | |
yield <html.input key="ONLY ME!" readOnly value={await $`time`.text()} /> | |
await sleep(1_234) | |
} | |
} | |
const sleep = (time: number) => new Promise(resolve => setTimeout(resolve, time)) | |
export function Demo() { | |
return ( | |
<Suspense fallback="loading…"> | |
<CurrentServerTime /> | |
</Suspense> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://x.com/shuding_/status/1770623199929078112?s=20
The AI SDK UI stream was implemented via nesting
<Suspense>
elements