Describe the bug
When using intentionally null value for a NumberInput, the component crashes with the stack trace below:
index.js:2177 Warning: A component is changing an uncontrolled input of type text to be controlled. Input elements should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://fb.me/react-controlled-components
in input (created by Context.Consumer)
in PseudoBox (created by Input)
in Input (created by NumberInputField)
in NumberInputField (at NumericEvaluator.tsx:72)
in div (created by Context.Consumer)
in Box (created by Flex)
in Flex (created by NumberInput)
in NumberInput (at NumericEvaluator.tsx:57)
Expected Behavior
NumberInput.value should be given null without issues.
I've run into this a few times over the past few days. Do you have any thoughts on this one @segunadebayo?
@aaronmcadam, yeah I'm aware.
It's related to a PR from @kripod I merged a while ago. I'll release a patch for it shortly.
I've fixed this issue and will publish a patch shortly.
As it stands, NumberInput can't be given a null value as it's not allowed by default in input fields. To support that scenario, we'll have to break the controlled/uncontrolled switching rule of React and I don't think it's worth it.
NumberInput returns a string | number depending on the current state of the value. To denote the absence of a value, use an empty string "".
I'll release a patch in a couple of hours.
Most helpful comment
@aaronmcadam, yeah I'm aware.
It's related to a PR from @kripod I merged a while ago. I'll release a patch for it shortly.