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

Add option to render stories in React.StrictMode #12734

Closed
oliviertassinari opened this issue Oct 11, 2020 · 12 comments
Closed

Add option to render stories in React.StrictMode #12734

oliviertassinari opened this issue Oct 11, 2020 · 12 comments

Comments

@oliviertassinari
Copy link
Contributor

oliviertassinari commented Oct 11, 2020

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.

@shilman
Copy link
Member

shilman commented Oct 11, 2020

@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.

@imshubhamsingh
Copy link

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

@shilman
Copy link
Member

shilman commented Oct 15, 2020

@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?

@imshubhamsingh
Copy link

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

@imshubhamsingh
Copy link

@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.

@tooppaaa
Copy link
Contributor

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

@imshubhamsingh
Copy link

@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).

@shilman
Copy link
Member

shilman commented Oct 16, 2020

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.

@shilman shilman closed this as completed Oct 16, 2020
@shilman
Copy link
Member

shilman commented Oct 16, 2020

Apologies @imshubhamsingh !

@oliviertassinari
Copy link
Contributor Author

Great :)

@shilman
Copy link
Member

shilman commented Oct 19, 2020

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

@shilman
Copy link
Member

shilman commented Nov 19, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants