-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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 #25091 from storybookjs/shilman/add-rsc
NextJS: Add experimental RSC support
- Loading branch information
Showing
10 changed files
with
137 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
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,10 @@ | ||
import type { Addon_DecoratorFunction } from '@storybook/types'; | ||
import { ServerComponentDecorator } from './rsc/decorator'; | ||
|
||
export const decorators: Addon_DecoratorFunction<any>[] = [ServerComponentDecorator]; | ||
|
||
export const parameters = { | ||
nextjs: { | ||
rsc: true, | ||
}, | ||
}; |
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,14 @@ | ||
import * as React from 'react'; | ||
import type { StoryContext } from '@storybook/react'; | ||
|
||
export const ServerComponentDecorator = ( | ||
Story: React.FC, | ||
{ parameters }: StoryContext | ||
): React.ReactNode => | ||
parameters?.nextjs?.rsc ? ( | ||
<React.Suspense> | ||
<Story /> | ||
</React.Suspense> | ||
) : ( | ||
<Story /> | ||
); |
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 const RSC = async ({ label }) => <>RSC {label}</>; | ||
|
||
export const Nested = async ({ children }) => <>Nested {children}</>; |
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,35 @@ | ||
import React from 'react'; | ||
import { RSC, Nested } from './RSC'; | ||
|
||
export default { | ||
component: RSC, | ||
args: { label: 'label' }, | ||
}; | ||
|
||
export const Default = {}; | ||
|
||
export const DisableRSC = { | ||
tags: ['test-skip'], | ||
parameters: { | ||
chromatic: { disable: true }, | ||
nextjs: { rsc: false }, | ||
}, | ||
}; | ||
|
||
export const Error = { | ||
tags: ['test-skip'], | ||
parameters: { | ||
chromatic: { disable: true }, | ||
}, | ||
render: () => { | ||
throw new Error('RSC Error'); | ||
}, | ||
}; | ||
|
||
export const NestedRSC = { | ||
render: (args) => ( | ||
<Nested> | ||
<RSC {...args} /> | ||
</Nested> | ||
), | ||
}; |
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
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
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