Skip to content

Commit 4be4e06

Browse files
erbilnasogunbErbil Nas
authored
docs(storybook): add new import type for nextjs (#985)
Co-authored-by: Ogun Babacan <[email protected]> Co-authored-by: Erbil Nas <[email protected]>
1 parent 33dd9a4 commit 4be4e06

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/using-baklava-in-next.stories.mdx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,29 @@ In the page, import the component using `dynamic` with ssr off.
5252
const Button = dynamic(() => import("@/components/Button"), { ssr: false });
5353
```
5454
55+
Or you can export the component as dynamic to avoid type errors.
56+
57+
```jsx
58+
59+
"use client";
60+
61+
import dynamic from 'next/dynamic';
62+
import type { ComponentProps } from 'react';
63+
import { BlButton } from "@trendyol/baklava/dist/baklava-react";
64+
65+
type ButtonProps = ComponentProps<typeof BlButton>;
66+
67+
const Button = (props: ButtonProps) => (
68+
<BlButton {...props}>Click me!</BlButton>
69+
);
70+
71+
const DynamicButton = dynamic<ButtonProps>(() =>
72+
Promise.resolve(Button)
73+
);
74+
75+
export default DynamicButton;
76+
```
77+
5578
[Here is the demo repository](https://github.com/trendyol/baklava/tree/next/examples/next-app-router-ssr). You can also preview it live with [StackBlitz](https://stackblitz.com/github/trendyol/baklava/tree/next/examples/next-app-router-ssr).
5679
5780
## Using with SSR

0 commit comments

Comments
 (0)