-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: suspense client component (#78)
This fixes an issue about adding scripts to the HTML document in development mode for HMR when the initial page don't use a client component, but a client component is rendered in a `<Suspense>` boundary. #77 Adds a test to verify this use case from now on.
- Loading branch information
Showing
6 changed files
with
71 additions
and
14 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 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,7 @@ | ||
"use client"; | ||
|
||
export default function ClientComponent() { | ||
return ( | ||
<button onClick={() => console.log("use client")}>Client Component</button> | ||
); | ||
} |
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,17 @@ | ||
import { Suspense } from "react"; | ||
import ClientComponent from "./client-component.jsx"; | ||
|
||
async function AsyncComponent() { | ||
await new Promise((resolve) => setTimeout(resolve, 100)); | ||
return <ClientComponent />; | ||
} | ||
|
||
export default function App() { | ||
return ( | ||
<div> | ||
<Suspense fallback={<div>Loading...</div>}> | ||
<AsyncComponent /> | ||
</Suspense> | ||
</div> | ||
); | ||
} |