Possible to dynamically set paramters via args? #13925
Unanswered
nathanshelly
asked this question in
Help
Replies: 1 comment 8 replies
-
Parameters are meant to be static, so changing them at runtime doesn't make sense. Args are parameters that are meant to be changed at runtime. They are available everywhere parameters are available:
So I think rather than using args to set parameters, you can just use args instead. Would that work for your use case? |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
👋 First off thanks for this amazing product! Migrated from v5 to v6 recently and controls inference from Typescript prop types is absolutely amazing.
I'm wondering if it's possible to set parameters of a story based on the args so that someone could play with parameters via controls.
Here's a trivial example of what I'm interested in:
Unfortunately setting that
parameters
inside the function doesn't have any effect in Storybook. If I add aconsole.log(Foo)
before thereturn <div>...
I can see that the parameters on theFoo
object are indeed being set but Storybook isn't updating based on it.My real use case here is with the storybook-addon-apollo-client. I would love to have a control that I could modify to change the mocks passed to the
MockedProvider
which are set on the parameters. Is there any way to achieve what I'm looking for?Beta Was this translation helpful? Give feedback.
All reactions