Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to dynamically set paramters via args? #13820

Closed
nathanshelly opened this issue Feb 5, 2021 · 0 comments
Closed

Possible to dynamically set paramters via args? #13820

nathanshelly opened this issue Feb 5, 2021 · 0 comments

Comments

@nathanshelly
Copy link

馃憢 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:

export function Foo({ fullscreen }) {
  Foo.parameters = { layout: fullscreen ? 'fullscreen' : 'centered' };

  return <div>This is a {fullscreen ? 'fullscreen' : 'centered'} component</div>;
}
Foo.args = { fullscreen: true };

Unfortunately setting that parameters inside the function doesn't have any effect in Storybook. If I add a console.log(Foo) before the return <div>... I can see that the parameters on the Foo 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?

@shilman shilman closed this as completed Feb 16, 2021
@storybookjs storybookjs locked and limited conversation to collaborators Feb 16, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants