You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This Storybook addon can be helpful if your components need special query parameters to work the way you want them to. It allows you to mock query params per story so that you can easily reproduce different states of your component.
In your story, define the query parameters you want to mock via the query special parameter:
importReactfrom"react";import{Button}from"../Button";exportdefault{component: Button,parameters: {query: {// example of mocking ?greeting="Hello world!"greeting: "Hello world!",},},};exportconstWithMockedSearch={render: ()=>{consturlParams=newURLSearchParams(document.location.search);constmockedParam=urlParams.get("greeting");return<div>Mockedvalue: {mockedParam}</div>;}}
Credits
While this addon was part of the Storybook monorepo, it received commits from the following authors:
Andrew Lisowski,
Brody McKee,
Clément DUNGLER,
Filipp Riabchun,
Gaëtan Maisse,
Gert Hengeveld,
Jon Palmer,
Lynn Chyi,
Michael Shilman,
Norbert de Langen,
Paul Rosania,
Renovate Bot,
Tom Coleman,
Varun Vachhar,
Yann Braga