Hello,
I seem to have found a bug where cleave.js throws a TypeError when its value prop is set to null through an update such as setState. Considering cleave.js allows the initial value of its value prop to be null, this behaviours seems to be unintentional.
Following the stack trace, this line seems to be the problem. Notice how it only checks for undefined but not for null.
A minimal case to reproduce can be found here: https://jsfiddle.net/xjkm5o0b/8/
Full stack trace:
Uncaught TypeError: Cannot read property 'toString' of null
at Object.componentWillReceiveProps (cleave-react.min.js:8)
at react-dom.js:5014
at measureLifeCyclePerf (react-dom.js:4479)
at ReactCompositeComponentWrapper.updateComponent (react-dom.js:5013)
at ReactCompositeComponentWrapper.receiveComponent (react-dom.js:4950)
at Object.receiveComponent (react-dom.js:11488)
at Object.updateChildren (react-dom.js:4293)
at ReactDOMComponent._reconcilerUpdateChildren (react-dom.js:10284)
at ReactDOMComponent._updateChildren (react-dom.js:10388)
at ReactDOMComponent.updateChildren (react-dom.js:10375)
I have the same issue, found a workaround to change null into undefined.
But it would be nice to have this fixed.
const val = value === null && undefined
<Cleave value={val} />
any updates?
Released in 1.5.4, thanks.
Most helpful comment
Released in 1.5.4, thanks.