Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
a169017c
Unverified
Commit
a169017c
authored
Mar 01, 2019
by
Tim Neutkens
Committed by
GitHub
Mar 01, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add docs for named exports using dynamic (#6502)
parent
5db0bef9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
4 deletions
+33
-4
README.md
packages/next/README.md
+33
-4
No files found.
packages/next/README.md
View file @
a169017c
...
...
@@ -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.
####
1.
Basic Usage (Also does SSR)
#### Basic Usage (Also does SSR)
```
jsx
import dynamic from 'next/dynamic'
...
...
@@ -1086,7 +1086,36 @@ function 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
import dynamic from 'next/dynamic'
...
...
@@ -1108,7 +1137,7 @@ function Home() {
export default Home
```
####
3.
With No SSR
#### With No SSR
```
jsx
import dynamic from 'next/dynamic'
...
...
@@ -1130,7 +1159,7 @@ function Home() {
export default Home
```
####
4.
With Multiple Modules At Once
#### With Multiple Modules At Once
```
jsx
import dynamic from 'next/dynamic'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment