rsnext/errors/invalid-dynamic-options-type.md
Hannes Bornö 466687e88e
SWC: Add error checks and tests to next-dynamic (#31683)
fixes #31520

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2021-11-26 14:22:28 +00:00

677 B

Invalid options type in a next/dynamic call

Why This Error Occurred

You have an invalid options type in a next/dynamic call. The options must be an object literal.

Possible Ways to Fix It

Before

import dynamic from 'next/dynamic'

const options = { loading: () => <p>...</p>, ssr: false }
const DynamicComponent = dynamic(() => import('../components/hello'), options)

After

import dynamic from 'next/dynamic'

const DynamicComponent = dynamic(() => import('../components/hello'), {
  loading: () => <p>...</p>,
  ssr: false,
})