2023-07-05 15:11:16 +02:00
|
|
|
---
|
|
|
|
title: 'Invalid options type in a `next/dynamic` call'
|
|
|
|
---
|
2021-11-26 15:22:28 +01:00
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
## Why This Error Occurred
|
2021-11-26 15:22:28 +01:00
|
|
|
|
|
|
|
You have an invalid options type in a `next/dynamic` call. The options must be an object literal.
|
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
## Possible Ways to Fix It
|
2021-11-26 15:22:28 +01:00
|
|
|
|
|
|
|
**Before**
|
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
```jsx filename="example.js"
|
2021-11-26 15:22:28 +01:00
|
|
|
import dynamic from 'next/dynamic'
|
|
|
|
|
|
|
|
const options = { loading: () => <p>...</p>, ssr: false }
|
|
|
|
const DynamicComponent = dynamic(() => import('../components/hello'), options)
|
|
|
|
```
|
|
|
|
|
|
|
|
**After**
|
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
```jsx filename="example.js"
|
2021-11-26 15:22:28 +01:00
|
|
|
import dynamic from 'next/dynamic'
|
|
|
|
|
|
|
|
const DynamicComponent = dynamic(() => import('../components/hello'), {
|
|
|
|
loading: () => <p>...</p>,
|
|
|
|
ssr: false,
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
## Useful Links
|
2021-11-26 15:22:28 +01:00
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
- [Dynamic Import](/docs/pages/building-your-application/optimizing/lazy-loading)
|