addon-knobs select knob with list of functions
See original GitHub issueDescribe the bug I have a component that is passed a function as a prop that determines how the component behaves under certain CSS breakpoints. There is a finite list of functions that can be passed, one for each site breakpoint in fact. When I pass an object of functions they are not rendered in the dropdown To Reproduce Steps to reproduce the behavior:
- Create a select knob for a prop like so
select('Disable From', { fromExtraLarge: () => null })
Expected behavior ‘Disable From’ to appear in the dropdown list
System:
- OS: MacOS
- Device: Macbook Pro 2018
- Browser: chrome
- Framework:react
- Addons: addon-knobs
- Version: 4.1.11
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
addon-knobs select knob with list of functions #5616 - GitHub
Describe the bug I have a component that is passed a function as a prop that determines how the component behaves under certain...
Read more >Knobs Addon | Storybook: Frontend workshop for UI ...
Storybook Addon Knobs allow you to edit props dynamically using the Storybook UI. You can also use Knobs as a dynamic variable inside...
Read more >Anyone knows the inner working of select knob in React ...
My question is: How does the storybook Knob select work to set the same component prop successfully but my setting it from the...
Read more >Top 5 @storybook/addon-knobs Code Examples - Snyk
To help you get started, we've selected a few @storybook/addon-knobs examples, based on popular ways it is used in public projects.
Read more >Addons | Knobs . withKnobs - complex select ⋅ Storybook
Knobs. with decorators. withKnobs. tweaks static values · tweaks static values organized in groups · dynamic knobs · complex select · Options Knob....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
There’s a way you can accomplish this:
It would be nice to display function signatures though. It’s common to have function props so I’d like to work toward a way to support them as their own knob type; however, my search hasn’t found much in the issues.
@shilman
I’m also interested in a knob that displays function signatures. I am in the process of building a reusable library and quite a few of them require some sort of callback as a prop, it would be nice if it could be included with the rest of the props in the knobs tab to show potential users what to expect, right there in the same page.
Currently I have left the functions out of the knobs tab and are replying on a readme for users to understand what callbacks to provide to the component.
Maybe something simple that signifies the prop is a function, and I could provide the signature to be displayed, and the field will be there to inform users that this is a prop for the component?