Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
override ssr option, update docs and tests
- Loading branch information
Showing
11 changed files
with
149 additions
and
62 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
9 changes: 6 additions & 3 deletions
9
test/integration/react-18/prerelease/components/dynamic-suspense.js
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 |
---|---|---|
@@ -1,12 +1,15 @@ | ||
import { Suspense } from 'react' | ||
import dynamic from 'next/dynamic' | ||
|
||
const Hello = dynamic(() => import('./hello'), { suspense: true }) | ||
const Hello = dynamic(() => import('./hello'), { | ||
ssr: false, | ||
suspense: false, | ||
}) | ||
|
||
export default function DynamicSuspense({ suspended }) { | ||
export default function SuspenseNoSSR({ thrown }) { | ||
return ( | ||
<Suspense fallback={'loading'}> | ||
<Hello suspended={suspended} /> | ||
<Hello thrown={thrown} /> | ||
</Suspense> | ||
) | ||
} |
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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import React from 'react' | ||
import ReactDOM from 'react-dom' | ||
|
||
export default function Hello({ suspended = false }) { | ||
if (suspended && typeof window !== 'undefined') { | ||
throw new Promise((resolve) => setTimeout(resolve, 1000)) | ||
export default function Hello({ thrown = false }) { | ||
// only throw on server side render | ||
if (thrown && typeof window === 'undefined') { | ||
throw new Promise((resolve) => setTimeout(resolve, 500)) | ||
} | ||
return <p>hello {ReactDOM.version}</p> | ||
} |
5 changes: 0 additions & 5 deletions
5
test/integration/react-18/prerelease/pages/suspense/content.js
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
test/integration/react-18/prerelease/pages/suspense/fallback.js
This file was deleted.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
test/integration/react-18/prerelease/pages/suspense/no-thrown.js
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,5 @@ | ||
import DynamicSuspense from '../../components/dynamic-suspense' | ||
|
||
export default function NoThrown() { | ||
return <DynamicSuspense thrown={false} /> | ||
} |
5 changes: 5 additions & 0 deletions
5
test/integration/react-18/prerelease/pages/suspense/thrown.js
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,5 @@ | ||
import DynamicSuspense from '../../components/dynamic-suspense' | ||
|
||
export default function Thrown() { | ||
return <DynamicSuspense thrown /> | ||
} |
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