-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Battle test RSC with Suspense + client components (#190)
* Inline Fiber.task/root into render_to * Add render-rsc and render-html * Move RSD test into test_RSC_model * Create test_RSC_html with async testing * Enable all tests for ReactDOM * Iterate over the demo with RSC + clients * Fix demo with imports * Renames to fix initial chunk id
- Loading branch information
Showing
20 changed files
with
464 additions
and
331 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from "react"; | ||
import { renderToPipeableStream } from "react-server-dom-webpack/server"; | ||
|
||
const DefferedComponent = async ({ sleep, children }) => { | ||
await new Promise((res) => setTimeout(() => res(), sleep * 1000)); | ||
return <span>Sleep {sleep}s, {children}</span>; | ||
}; | ||
|
||
const decoder = new TextDecoder(); | ||
|
||
const debug = (readableStream) => { | ||
const reader = readableStream.getReader(); | ||
const debugReader = ({ done, value }) => { | ||
if (done) { | ||
console.log("Stream complete"); | ||
return; | ||
} | ||
console.log(decoder.decode(value)); | ||
console.log(" "); | ||
return reader.read().then(debugReader); | ||
}; | ||
reader.read().then(debugReader); | ||
}; | ||
|
||
const sleep = (seconds) => | ||
new Promise((res) => setTimeout(res, seconds * 1000)); | ||
|
||
const App = () => ( | ||
<React.Suspense fallback="Fallback 1"> | ||
<DefferedComponent sleep={1}> | ||
<React.Suspense fallback="Fallback 2"> | ||
<DefferedComponent sleep={1}>"lol"</DefferedComponent> | ||
</React.Suspense> | ||
</DefferedComponent> | ||
</React.Suspense> | ||
); | ||
|
||
const { pipe } = renderToPipeableStream(<App />); | ||
|
||
pipe(process.stdout); |
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[@react.component] | ||
let make = () => { | ||
<hr | ||
className={Cx.make([ | ||
"block", | ||
"w-full", | ||
"h-px", | ||
Theme.border("gray-700"), | ||
])} | ||
/>; | ||
}; |
Oops, something went wrong.