Skip to content

Commit ab14efa

Browse files
committed
remove unstable doc
1 parent 9ff8f57 commit ab14efa

File tree

7 files changed

+6
-77
lines changed

7 files changed

+6
-77
lines changed

docs/advanced-features/dynamic-import.md

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -156,45 +156,3 @@ function Home() {
156156

157157
export default Home
158158
```
159-
160-
## With suspense
161-
162-
In React 18, `<Suspense>` and `React.lazy` can work with SSR. So dynamic provide an option `suspense` to let you choose if you want to load a component under suspense.
163-
164-
```jsx
165-
import { Suspense } from 'react'
166-
import dynamic from 'next/dynamic'
167-
168-
const Profile = dynamic(() => import('./profile'), { suspense: true })
169-
170-
function Home() {
171-
return (
172-
<div>
173-
<Suspense fallback={'loading...'}>
174-
<Profile />
175-
</Suspense>
176-
</div>
177-
)
178-
}
179-
180-
export default Home
181-
```
182-
183-
If you set option `suspense` to true, other options will be omitted, delegating rendering control to React `<Suspense />`.
184-
It's similar to using `React.lazy` directly, but `next/dynamic` will support mode like CSR and SSG.
185-
186-
To use `suspense`, you need to enable `reactRoot` and `concurrentFeatures` in `next.config.js`.
187-
188-
Note: `reactRoot` will be enabled by default when using React 18.
189-
190-
```jsx
191-
// next.config.js
192-
module.exports = {
193-
experimental: {
194-
reactRoot: true,
195-
concurrentFeatures: true,
196-
},
197-
}
198-
```
199-
200-
If you only enable `reactRoot` but not `concurrentFeatures`, suspense will always render fallbacks on server side.

errors/no-suspense-in-blocking-mode.md

Lines changed: 0 additions & 25 deletions
This file was deleted.

packages/next/build/webpack-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ export default async function getBaseWebpackConfig(
11851185
config.reactStrictMode
11861186
),
11871187
'process.env.__NEXT_REACT_ROOT': JSON.stringify(hasReactRoot),
1188-
'process.env.__NEXT_CONCURRENT_MODE': JSON.stringify(
1188+
'process.env.__NEXT_CONCURRENT_FEATURES': JSON.stringify(
11891189
config.experimental.concurrentFeatures && hasReactRoot
11901190
),
11911191
'process.env.__NEXT_OPTIMIZE_FONTS': JSON.stringify(

packages/next/server/render.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,8 +1007,7 @@ export async function renderToHTML(
10071007
buffers.push(chunk)
10081008
})
10091009
stream.once('end', () => {
1010-
const content = Buffer.concat(buffers).toString('utf-8')
1011-
resolve(content)
1010+
resolve(Buffer.concat(buffers).toString('utf-8'))
10121011
})
10131012

10141013
const {

packages/next/shared/lib/dynamic.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,12 @@ export default function dynamic<P = {}>(
114114
loadableOptions = { ...loadableOptions, ...options }
115115

116116
const suspenseOptions = loadableOptions as LoadableSuspenseOptions<P>
117-
if (!process.env.__NEXT_CONCURRENT_MODE) {
117+
if (!process.env.__NEXT_CONCURRENT_FEATURES) {
118118
// Error if react root is not enabled and `suspense` option is set to true
119119
if (!process.env.__NEXT_REACT_ROOT && suspenseOptions.suspense) {
120+
// TODO: add error doc when this feature is stable
120121
throw new Error(
121-
`Disallowed suspense option usage with next/dynamic, read more: https://nextjs.org/docs/messages/page-without-valid-component.`
122+
`Disallowed suspense option usage with next/dynamic in blocking mode`
122123
)
123124
}
124125
suspenseOptions.suspense = false

test/integration/react-18/app/components/bar.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ import { useCachedPromise } from './promise-cache'
44

55
const Foo = dynamic(() => import('./foo'), {
66
suspense: true,
7-
loadableGenerated: {
8-
modules: ['./foo'],
9-
webpack: [require.resolveWeak('./foo')],
10-
},
117
})
128

139
export default function Bar() {

test/integration/react-18/test/basics.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default (context) => {
1919
expect(res2.status).toBe(200)
2020
})
2121

22-
it('should not preload modules on server side', async () => {
22+
it('should render fallback without preloads on server side', async () => {
2323
const html = await renderViaHTTP(context.appPort, '/suspense/no-preload')
2424
const $ = cheerio.load(html)
2525
const nextData = JSON.parse($('#__NEXT_DATA__').text())

0 commit comments

Comments
 (0)