-
-
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 #25591 from storybookjs/shilman/refactor-client-rsc
React: Refactor RSC out of Next
- Loading branch information
Showing
13 changed files
with
66 additions
and
49 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,31 @@ | ||
import * as React from 'react'; | ||
import semver from 'semver'; | ||
import type { Addon_DecoratorFunction } from '@storybook/types'; | ||
import type { StoryContext } from './types'; | ||
|
||
export const ServerComponentDecorator = ( | ||
Story: React.FC, | ||
{ parameters }: StoryContext | ||
): React.ReactNode => { | ||
if (!parameters?.react?.rsc) return <Story />; | ||
|
||
const major = semver.major(React.version); | ||
const minor = semver.minor(React.version); | ||
if (major < 18 || (major === 18 && minor < 3)) { | ||
throw new Error('React Server Components require React >= 18.3'); | ||
} | ||
|
||
return ( | ||
<React.Suspense> | ||
<Story /> | ||
</React.Suspense> | ||
); | ||
}; | ||
|
||
export const decorators: Addon_DecoratorFunction<any>[] = [ServerComponentDecorator]; | ||
|
||
export const parameters = { | ||
react: { | ||
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
declare var STORYBOOK_ENV: 'react'; | ||
declare var FRAMEWORK_OPTIONS: any; | ||
declare var LOGLEVEL: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent' | undefined; | ||
declare var FEATURES: import('@storybook/types').StorybookConfigRaw['features']; |
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