forked from laptou/astro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes using React.lazy and Suspense (withastro#3160)
* Revert "Revert "Fixes using React.lazy and Suspense"" This reverts commit e621c2f. * Adds a changeset * Fix ts errors * Remove netlify metadata folder
- Loading branch information
Showing
4 changed files
with
53 additions
and
6 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
test/fixtures/react-component/src/components/LazyComponent.jsx
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,9 @@ | ||
import React from 'react'; | ||
|
||
export const LazyComponent = () => { | ||
return ( | ||
<span id="lazy">inner content</span> | ||
); | ||
}; | ||
|
||
export default LazyComponent; |
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,14 @@ | ||
import React, { Suspense } from 'react'; | ||
const LazyComponent = React.lazy(() => import('./LazyComponent.jsx')); | ||
|
||
export const ParentComponent = () => { | ||
return ( | ||
<div id="outer"> | ||
<Suspense> | ||
<LazyComponent /> | ||
</Suspense> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ParentComponent; |
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 '../components/Suspense.jsx'; | ||
--- | ||
|
||
<html> | ||
<head> | ||
<!-- Head Stuff --> | ||
</head> | ||
<body> | ||
<div id="client"> | ||
<Suspense client:load /> | ||
</div> | ||
<div id="server"> | ||
<Suspense /> | ||
</div> | ||
</body> | ||
</html> |
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