Skip to content
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

Remove restrictions on props passed to components #13729

Closed
bebbi opened this issue Jan 26, 2021 · 3 comments
Closed

Remove restrictions on props passed to components #13729

bebbi opened this issue Jan 26, 2021 · 3 comments

Comments

@bebbi
Copy link

bebbi commented Jan 26, 2021

For a visualization graph I am passing a d3 graph structure with cycles.

Storybook complains that it cannot deal with a prop with cycles.

Yes, it's easy enough to work around that issue by wrapping the graph in a function prop that returns it, but it feels awkward to change the component signature to accommodate storybook.

Wouldn't it be important for Storybook to support any kind of props?

@phated
Copy link
Contributor

phated commented Jan 27, 2021

Good question!

Storybook communicates between your component preview and the "manager" (UI and addons surrounding the components) using postMessage. That method doesn't allow JS objects to be sent, so your props need to be stringified before being sent and JSON.stringify doesn't support cycles.

@bebbi
Copy link
Author

bebbi commented Jan 27, 2021

Thanks for the info @phated. Perhaps, since it can accept functions, it might be able to transparently wrap/unwrap props with cycles into functions to circumvent that limitation.

@phated
Copy link
Contributor

phated commented Jan 27, 2021

@bebbi Hmmm, I was just looking at the function caveats in https://github.com/storybookjs/telejson and the behavior seems a bit different than what you'd expect with cycles (specifically the lazy eval and performance implications). 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants