input-moment icon indicating copy to clipboard operation
input-moment copied to clipboard

Moment.js mutability issue (+validation)

Open Enieste opened this issue 7 years ago • 0 comments

Hello! I'm trying to add a validation to the component, conditionally setting state in the onChange callback. It seems it doesn't work really well due moment.js object mutability.

See the screencast attached and the commit https://github.com/Enieste/input-moment/commit/14e04be2cf6c1355fbc714db3d4acf099b8ebe82 (the time of screencast create is around 6:10 PM)

One way to handle this is passing moment={moment(this.state.m)} (i.e. clone of an object) but the component will still remain partially buggy (you can check yourself, moving the slider towards the right quick enough).

Not that the bug can be reproduced if you move the slider quick enough. You'll have a different output depending on slider movement speed.

Screencast: https://www.youtube.com/watch?v=FbqMIWDJMrk

Hope it makes sense.

Enieste avatar Apr 05 '17 11:04 Enieste