-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20066 from storybookjs/valentin/document-next-dyn…
…amic Add story for next/dynamic usage
- Loading branch information
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
code/frameworks/nextjs/template/stories/DynamicImport.stories.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import dynamic from 'next/dynamic'; | ||
import React, { Suspense } from 'react'; | ||
|
||
const DynamicComponent = dynamic(() => import('./dynamic-component'), { | ||
ssr: false, | ||
}); | ||
|
||
function Component() { | ||
return ( | ||
<Suspense fallback="Loading..."> | ||
<DynamicComponent /> | ||
</Suspense> | ||
); | ||
} | ||
|
||
export default { | ||
component: Component, | ||
}; | ||
|
||
export const Default = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React from 'react'; | ||
|
||
export default function DynamicComponent() { | ||
return <div>I am a dynamically loaded component</div>; | ||
} |