Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Update the React Native init to include v8 dependencies #29273

Merged
merged 3 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions code/lib/create-storybook/src/generators/REACT_NATIVE/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@ const generator = async (

const reactVersion = packageJson.dependencies.react;

const controlsPeerDependencies = [
const peerDependencies = [
'react-native-safe-area-context',
'@react-native-async-storage/async-storage',
'@react-native-community/datetimepicker',
'@react-native-community/slider',
'react-native-reanimated',
'react-native-gesture-handler',
'@gorhom/bottom-sheet',
'react-native-svg',
].filter((dep) => !packageJson.dependencies[dep] && !packageJson.devDependencies[dep]);

const packagesToResolve = [
...controlsPeerDependencies,
...peerDependencies,
'@storybook/addon-ondevice-controls',
'@storybook/addon-ondevice-actions',
'@storybook/react-native',
Expand Down Expand Up @@ -57,7 +61,8 @@ const generator = async (
await copyTemplateFiles({
packageManager,
renderer: 'react-native',
language: SupportedLanguage.TYPESCRIPT_3_8,
// this value for language is not used since we only ship the ts template. This means we just fallback to @storybook/react-native/template/cli.
language: SupportedLanguage.TYPESCRIPT_4_9,
destination: storybookConfigFolder,
});
};
Expand Down
9 changes: 6 additions & 3 deletions code/lib/create-storybook/src/initiate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,13 @@ export async function doInitiate(options: CommandOptions): Promise<

${picocolors.inverse(' ' + "export {default} from './.storybook';" + ' ')}

2. Enable transformer.unstable_allowRequireContext in your metro config
2. Wrap your metro config with the withStorybook enhancer function like this:

For a more detailed guide go to:
${picocolors.cyan('https://github.com/storybookjs/react-native#existing-project')}
${picocolors.inverse(' ' + "const withStorybook = require('@storybook/react-native/metro/withStorybook');" + ' ')}
${picocolors.inverse(' ' + 'module.exports = withStorybook(defaultConfig);' + ' ')}

For more details go to:
${picocolors.cyan('https://github.com/storybookjs/react-native#getting-started')}

Then to run your Storybook, type:

Expand Down
Loading