Closed artaommahe closed 11 months ago
I'm aware of this behaviour. I'm working on a v2 that will fix that issue. For now, as a workaround, you can declare your component outside the story object:
function DefaultComponent() {
const [value, setValue] = useState(0);
return <Counter value={value} onClick={() => setValue(value + 1)} />;
}
export const Default = {
render: () => <DefaultComponent />
}
@artaommahe I have published a RC for the v2, can you give it a try ?
https://github.com/JesusTheHun/storybook-addon-react-router-v6/releases/tag/v2.0.0-rc.0
@JesusTheHun it works!
Having this component
and this story with custom render function
The component will not be re-rendered on button clicks if
withRouter
decorator is used. Removing decorator fixes the issue.Reproduction - https://stackblitz.com/edit/storybook-addon-react-router-usestate-issue?file=src%2FCounter.stories.jsx
Libraries