Storybook: Add option to render stories in React.StrictMode

Created on 11 Oct 2020  路  12Comments  路  Source: storybookjs/storybook

Is your feature request related to a problem? Please describe

I would like to render all my stories in strict mode, to anticipate this mode becoming the default in React.

Describe the solution you'd like

I have noticed the global env XSTORYBOOK_EXAMPLE_APP but it seems to be private. It's not documented.

Describe alternatives you've considered

Next.js offers interesting options: https://nextjs.org/docs/api-reference/next.config.js/react-strict-mode.

We strongly suggest you enable Strict Mode in your Next.js application to better prepare your application for the future of React.

Additional context

StrictMode is enabled by default in Create React App. I'm opening the issue because we go a bug reported linked to our workflow where we don't have StrictMode enabled.

P1 react feature request good first issue help wanted

Most helpful comment

Great :)

All 12 comments

@oliviertassinari this should be an easy one and worthwhile. PRs welcome and if nothing comes in I'll try to make sure it happens for 6.1.

Hey @shilman I would like to give it a shot.

@imshubhamsingh ok I'm thinking we should add it as an option to .storybook/main.js:

module.exports = {
  reactOptions: {
    strictMode: true,
  }
}

Like we do for fastRefresh: https://github.com/storybookjs/storybook/blob/next/app/react/src/server/types.ts#L6-L11

Is that enough to get you started?

yeah. This will help. Thanks 鉁岋笍, If I have any doubt I'll reach out here or on discord server.

@shilman I see @tooppaaa has already submitted the PR for this. Please assign the PR to the respective individual so that two people are not working on the same thing at once. Thank you for your time.

@imshubhamsingh ohhh I'm so sorry I didn't saw your messages in this issue..

@tooppaaa no worries. I would request you sincerely that you don't repeat such mistake with others. People put in a lot of effort and time understanding the issue and try to solve it (as you would also have).

Huzzah!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.1.0-alpha.25 containing PR #12781 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb upgrade --prerelease

Closing this issue. Please re-open if you think there's still more to do.

Apologies @imshubhamsingh !

Great :)

Son of a gun!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.1.0-alpha.27 containing PR #12810 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb upgrade --prerelease

Gadzooks!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.1.0 containing PR #12781 that references this issue. Upgrade today to the @latest NPM tag to try it out!

npx sb upgrade
Was this page helpful?
0 / 5 - 0 ratings