-
Notifications
You must be signed in to change notification settings - Fork 28
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
Cannot change resourceContext between stories #76
Comments
Yeah, currently only |
In my case, I was able to resolve the current situation by mocking |
Still waiting for #145 as UniversalRouter is not exported. |
Hi @theKashey , I managed to create a workaround for this without needing to override any imports. You can create a decorator utilising export const withRouterDecoratorFn = ({ resources }: RouterDecoratorProps = {}): DecoratorFn =>
function RouterDecorator(Story) {
defaultRegistry.stores.clear(); // destroys existing react-sweet-state stores
return (
<Router
key={key} // key for uniqueness
routes={routes}
history={history}
resourceContext={routerContext} // context will be fresh for every mount (instantiating a new store)
>
<Story />
</Router>
);
}; Codesandbox demo: https://codesandbox.io/s/react-resource-router-basic-routing-example-forked-qt67q6 |
Please remove As for the |
Discovered in Storybook environment, when was not able to reset
resourceContext
between different stories.Expectation: mounting/unmounting Router and especially MemoryRouter are not by previously used components.
The text was updated successfully, but these errors were encountered: