question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Knobs numbers return null instead of undefined

See original GitHub issue

Describe 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

  1. Create a React/Angular component with default value and write a story for it.
  2. 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
alfnielsencommented, Apr 24, 2019

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 undefined

2reactions
stale[bot]commented, Jul 26, 2019

Hey 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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found