react-debounce-input icon indicating copy to clipboard operation
react-debounce-input copied to clipboard

Value doesn't clear if undefined

Open chrispday opened this issue 8 years ago • 3 comments

If the value prop is bound using an undefined value then it appears that when the component is rendered it remembers the old value. Is this by design?

chrispday avatar Sep 21 '16 08:09 chrispday

Probably related to #40

chrispday avatar Sep 22 '16 00:09 chrispday

If you pass undefined to the value prop, then component becomes uncontrolled and React will give a warning about it. Not sure if this needs to be fixed... Tho I have a PR to let it work as uncontrolled component #33, currently it does not make much sense to have onChange and pass value={undefined}, that would def trigger warning.

nkbt avatar Oct 09 '16 07:10 nkbt

I was binding value={store.someVar}, which starts as undefined like an "empty" value. I can then onChange={e => dispatchSetSomeVar(e)} to set the someVar in the store via reducer.

When you try this with the current version, the store updates but what's displayed in the control doesn't.

HTH!

chrispday avatar Oct 11 '16 20:10 chrispday