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

React 18 createRoot supports #18045

Closed
sivaraj-v opened this issue Apr 25, 2022 · 17 comments
Closed

React 18 createRoot supports #18045

sivaraj-v opened this issue Apr 25, 2022 · 17 comments

Comments

@sivaraj-v
Copy link

Feature looking for React 18 createRoot in storybook

https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html#updates-to-client-rendering-apis

I'm getting warning as follow,

image

image

Currently I'm using following version,

"@storybook/addon-a11y": "6.4.22",
"@storybook/addon-actions": "6.4.22",
 "@storybook/addon-jest": "6.4.22",
"@storybook/addon-viewport": "6.4.22",
"@storybook/builder-webpack5": "6.4.22",
"@storybook/manager-webpack5": "6.4.22",
 "@storybook/react": "6.4.22",
 
@Stunext
Copy link

Stunext commented Apr 25, 2022

You need to wait for version ^6.5 or use some of the alpha or beta versions. Keep in mind that as an "alpha/beta" version not all bugs are fixed.

@shilman
Copy link
Member

shilman commented Apr 25, 2022

Try upgrading to the latest 6.5 prerelease:

npx sb@next upgrade --prerelease

That will fix user code. Storybook's own UI is written in React 17, so it may also generate a warning. But that's safe to ignore for now. We'll rewrite the UI in React 18 for SB 7.0 which is coming next.

@sivaraj-v
Copy link
Author

Thanks @shilman and @Stunext

@latata
Copy link

latata commented Jun 29, 2022

It looks like in the latest version of storybook (6.5.9) still uses old ReactDOM.render method instead of createRoot. Are there plans to change it?

@shilman
Copy link
Member

shilman commented Jun 30, 2022

@latata do you have a reproduction of this? it should use the new root API if you're using react18 in your project. More info here: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#react18-new-root-api

@bstaruk
Copy link

bstaruk commented Jul 5, 2022

@shilman Here is a repo which has just 2 commits (CRA init, then storybook init), which reproduces the issue:

https://github.com/bstaruk/storybook-18045

Screen Shot 2022-07-05 at 7 44 26 AM

edit: Using node 16.15.0

@Semigradsky
Copy link

Semigradsky commented Jul 6, 2022

ReactDOM.render(<Root key="root" provider={provider} />, domNode);

@niug
Copy link

niug commented Jul 22, 2022

I have the same problem. Do you know how to solve it, even if it is a temporary solution?

@Semigradsky
Copy link

Temporary solution - just ignore it. It is warning in Storybook UI, not in your components.

@niug
Copy link

niug commented Jul 26, 2022

Hi @Semigradsky, but my components don't loading correctly, are always in an inifinite loading loop:

image

@Semigradsky
Copy link

@niug I don't think that this is related to warning. Latest stable storybook (6.5.9) works great with React 18 for me.

@niug
Copy link

niug commented Jul 26, 2022

ok @Semigradsky, I'm using this version, here it's my package.json:

image

Some idea why don't load the component page? Thanks.

@Semigradsky
Copy link

@niug I have no idea. Create a new issue with a link to a reproducible demo

@uh92
Copy link

uh92 commented Sep 11, 2022

image
image
I'm not sure correctness of result but twice result the same

@uh92
Copy link

uh92 commented Sep 11, 2022

I saw comment from @shilman how to fix but doesn't work

@Semigradsky
Copy link

@vladgorbachev why did you write it here? It is totally different issue, open your own.

Also, you use 7.x version - it has break changes, read the migration guide at first (MIGRATION.md).

@shilman shilman closed this as completed Oct 30, 2022
Copy link
Member

shilman commented Oct 30, 2022

Closing this as fixed by #17215

This is available in 6.5+

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

8 participants