Cleave.js: Updating value prop to null causes TypeError

Created on 19 Sep 2018  路  3Comments  路  Source: nosir/cleave.js

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)

Most helpful comment

Released in 1.5.4, thanks.

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mrozado picture mrozado  路  3Comments

vfonic picture vfonic  路  3Comments

periabyte picture periabyte  路  7Comments

ozkxr picture ozkxr  路  3Comments

ArtyomBist picture ArtyomBist  路  6Comments