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

Nested Router error after upgrading to Storybook v6.4 from v6.3 #17712

Closed
wellyshen opened this issue Mar 14, 2022 · 6 comments
Closed

Nested Router error after upgrading to Storybook v6.4 from v6.3 #17712

wellyshen opened this issue Mar 14, 2022 · 6 comments

Comments

@wellyshen
Copy link

wellyshen commented Mar 14, 2022

Thank you for this great platform. We're using react-router v6 in our project and some of our storybook components are using the useLoaction() hook of react-router. So we provide a location for the components by a decorator like this. After we upgrade Storybook from v6.3 to v6.4 we encounter the following error. So now we have to lock the minor version as ~6.3.8. Do you have any suggestions for that? Thank you.

截圖 2022-03-14 下午3 38 48

@wellyshen wellyshen changed the title Nested Router error Nested Router error after upgrading to Storybook v6.4 Mar 14, 2022
@wellyshen wellyshen changed the title Nested Router error after upgrading to Storybook v6.4 Nested Router error after upgrading to Storybook v6.4 from v6.3 Mar 14, 2022
@shilman
Copy link
Member

shilman commented Mar 15, 2022

We've updated the way we handle react-router in 6.5. Try upgrading to the latest prerelease:

npx sb@next upgrade --prerelease

Does that fix it?

@karsai5
Copy link

karsai5 commented Mar 29, 2022

I still get the error when running v6.5.0-alpha.51. I'm using a MemoryRouter in a decorator, similar to what @wellyshen described

Screen Shot 2022-03-29 at 3 17 49 pm

@shilman
Copy link
Member

shilman commented Mar 29, 2022

@karsai5 can you do an npm ls or yarn why to make sure you're running the 6.5 version of all storybook packages?

@karsai5
Copy link

karsai5 commented Mar 29, 2022

I get the following result for @storybook/react
Screen Shot 2022-03-29 at 3 27 06 pm

previously I was running 6.4.19 which worked fine. It's only since I updated to react-router 6 which doesn't seem to support nested <Router/>'s anymore that it stopped working.

@karsai5
Copy link

karsai5 commented Mar 29, 2022

After doing some more reading I found this comment which seems to work in case anyone else runs into the same issue remix-run/react-router#7375 (comment).

My decorator now looks like this:

(Story) => (
  <UNSAFE_LocationContext.Provider value={null}>
    <MemoryRouter>
      <Story />
    </MemoryRouter>
  </UNSAFE_LocationContext.Provider>
),

@shilman
Copy link
Member

shilman commented Jun 8, 2023

We’re cleaning house! Storybook has changed a lot since this issue was created and we don’t know if it’s still valid. Please open a new issue referencing this one if:

@shilman shilman closed this as not planned Won't fix, can't repro, duplicate, stale Jun 8, 2023
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

3 participants