Knobs numbers return null instead of undefined
See original GitHub issueDescribe the bug I know somebody would say that this is not an error, but knobs ‘number’ dont work with default parameter values because it returns null instead of undefined on empty string.
To Reproduce
- Create a React/Angular component with default value and write a story for it.
- When you delete all context from the knobs input in storybook the value in the component will be null instead of the default value. (And this is because default values only works with undefined and not null)
Expected behavior expect undefined, not null
Code snippets storybook/addons/knobs/src/converters.js Line 18:
toFloat: value => (value === '' ? null : parseFloat(value)),
Should be:
toFloat: value => (value === '' ? undefined : parseFloat(value)),
bs and good in general 😃
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (2 by maintainers)
Top Results From Across the Web
What reason is there to use null instead of undefined in ...
In the case of null , as a value type it means an empty value has been assigned to a variable, but the...
Read more >null vs. undefined: Can I use only one? | by OOO - Medium
null and undefined are used interchangeably to represent non-value. Why can't I just stick with one? At first, I used both because they...
Read more >Fun JavaScript: Safely dealing with undefined/null values ...
Let's pretend there is a number we want to apply an operations to, and if that number is undefined/null, we want to avoid...
Read more >What reason is there to use null instead of undefined ... - Quora
It is always prefered to Use Null instead because when the value is only declared Javascript assigns a value of Undefined automatically so...
Read more >7 Tips to Handle undefined in JavaScript - Dmitri Pavlutin
null , but also undefined , represent in JavaScript empty values. ... returns the initial array [10] without modifications, instead of the ...
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 FreeTop 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
Top GitHub Comments
I dont believe it’s a duplicate of #4487 but clearly related.
The problem with ‘select’ knobs require another solution then this does.
The ‘number’ knobs is because it’s has been choosen at some point to return ‘null’ in
storybook/addons/knobs/src/converters.js
for numbers that a empty string instead of undefinedHey there, it’s me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!