Skip to content

Commit

Permalink
Merge pull request #20066 from storybookjs/valentin/document-next-dyn…
Browse files Browse the repository at this point in the history
…amic

Add story for next/dynamic usage
  • Loading branch information
valentinpalkovic authored Dec 3, 2022
2 parents 366c067 + 934ca01 commit 5ec53aa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
20 changes: 20 additions & 0 deletions code/frameworks/nextjs/template/stories/DynamicImport.stories.jsx
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 = {};
5 changes: 5 additions & 0 deletions code/frameworks/nextjs/template/stories/dynamic-component.js
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>;
}

0 comments on commit 5ec53aa

Please sign in to comment.