JesusTheHun / storybook-addon-remix-react-router

Use your app router in your stories. A decorator made for Remix React Router and Storybook
Apache License 2.0
48 stars 11 forks source link

withRouter is preventing useArgs to be called in stories in Storybook V7 #33

Closed emad-ms closed 1 year ago

emad-ms commented 1 year ago

withRouter is not letting useArgs() work in Storybook 7. Here are two discussions for issues within storybook 7 that looks related: https://github.com/storybookjs/storybook/issues/12006#issuecomment-1553891230 https://github.com/storybookjs/testing-react/issues/30#issuecomment-1542479018

It seems the reason can be the way story() is being called and it's not being called like a React node so it loses its args state. https://github.com/JesusTheHun/storybook-addon-react-router-v6/blob/0b95fa7465ce4269051645dbfa0138c99f98f2d4/src/withRouter.tsx#LL44C9-L44C44

JesusTheHun commented 1 year ago

AFAICT the SB team says you should not use this hook inside a React component. It's unclear why should support this, or how

emad-ms commented 1 year ago

I couldn't find anything regarding using useArgs() inside a Story as a bad practice. But even if you don't use it inside a story and just use it in an AddOn still the AddOn will have the same issue.

JesusTheHun commented 1 year ago

What do you expect me to do ?