Unverified Commit a169017c authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Add docs for named exports using dynamic (#6502)

parent 5db0bef9
...@@ -1066,7 +1066,7 @@ Since Next.js supports dynamic imports with SSR, you could do amazing things wit ...@@ -1066,7 +1066,7 @@ Since Next.js supports dynamic imports with SSR, you could do amazing things wit
Here are a few ways to use dynamic imports. Here are a few ways to use dynamic imports.
#### 1. Basic Usage (Also does SSR) #### Basic Usage (Also does SSR)
```jsx ```jsx
import dynamic from 'next/dynamic' import dynamic from 'next/dynamic'
...@@ -1086,7 +1086,36 @@ function Home() { ...@@ -1086,7 +1086,36 @@ function Home() {
export default Home export default Home
``` ```
#### 2. With Custom Loading Component #### With named exports
```jsx
// components/hello.js
export function Hello() {
return (
<p>Hello!</p>
)
}
```
```jsx
import dynamic from 'next/dynamic'
const DynamicComponent = dynamic(() => import('../components/hello').then((mod) => mod.Hello))
function Home() {
return (
<div>
<Header />
<DynamicComponent />
<p>HOME PAGE is here!</p>
</div>
)
}
export default Home
```
#### With Custom Loading Component
```jsx ```jsx
import dynamic from 'next/dynamic' import dynamic from 'next/dynamic'
...@@ -1108,7 +1137,7 @@ function Home() { ...@@ -1108,7 +1137,7 @@ function Home() {
export default Home export default Home
``` ```
#### 3. With No SSR #### With No SSR
```jsx ```jsx
import dynamic from 'next/dynamic' import dynamic from 'next/dynamic'
...@@ -1130,7 +1159,7 @@ function Home() { ...@@ -1130,7 +1159,7 @@ function Home() {
export default Home export default Home
``` ```
#### 4. With Multiple Modules At Once #### With Multiple Modules At Once
```jsx ```jsx
import dynamic from 'next/dynamic' import dynamic from 'next/dynamic'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment