silverwolf-x/project / errors /invalid-dynamic-suspense.mdx
silverwolf-x's picture
download
raw
1.39 kB
---
title: 'Invalid Usage of `suspense` Option of `next/dynamic`'
---
## Why This Error Occurred
- You are using `{ suspense: true }` with React version older than 18.
- You are using `{ suspense: true, ssr: false }`.
- You are using `{ suspense: true, loading }`.
## Possible Ways to Fix It
**If you are using `{ suspense: true }` with React version older than 18**
- You can try upgrading to React 18 or newer
- If upgrading React is not an option, remove `{ suspense: true }` from `next/dynamic` usages.
**If you are using `{ suspense: true, ssr: false }`**
Next.js will use `React.lazy` when `suspense` is set to true. React 18 or newer will always try to resolve the Suspense boundary on the server. This behavior can not be disabled, thus the `ssr: false` is ignored with `suspense: true`.
- You should write code that works in both client-side and server-side.
- If rewriting the code is not an option, remove `{ suspense: true }` from `next/dynamic` usages.
**If you are using `{ suspense: true, loading }`**
Next.js will use `React.lazy` when `suspense` is set to true, when your dynamic-imported component is loading, React will use the closest suspense boundary's fallback.
You should remove `loading` from `next/dynamic` usages, and use `<Suspense />`'s `fallback` prop.
## Useful Links
- [Dynamic Import Suspense Usage](/docs/pages/guides/lazy-loading#nextdynamic)

Xet Storage Details

Size:
1.39 kB
·
Xet hash:
864c9522776501e98964cd98139cffb1a95a6dffcccaa42ad77d31baeefda598

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.