-
Notifications
You must be signed in to change notification settings - Fork 9
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
[Bug] #1
Comments
We should the following query-parameters from ever being deleted: |
I encountered this on our project, not really sure if this is maintained. Addon was helpful enough and it was even putting the wrong query parameters into snapshots and a few other things, so felt good to fix. Taking from the original idea of a Happy to go back to the addon if that resolves it. I will note, a bit contrary to the OP idea, setting the |
would smtg like that work? const withQuery = (Story, context) => {
const [, forceRerender] = useState();
const query = context?.parameters?.query;
useLayoutEffect(() => {
const href = window?.location?.href;
if (!query || !href) return;
const url = new URL(href);
for (const [key, value] of Object.entries(query)) {
url.searchParams.set(key, value);
}
window.history.replaceState(window.history.state, "", url.href);
forceRerender({});
return () => {
// restore original url
window.history.replaceState(window.history.state, "", href);
};
}, [query]);
return <Story {...context} />;
}; |
This addon should clean up the added query parameters after navigating away from the story.
We could use the
useEffect
from@storybook/addons
The text was updated successfully, but these errors were encountered: