react-throttle icon indicating copy to clipboard operation
react-throttle copied to clipboard

Not debouncing when input has a value?

Open fabimc opened this issue 8 years ago • 4 comments

Use case

<Debounce time="400" handler="onChange">
  <TextField type='number' id='tempMin' value={this.props.temp.min} hintText='Min threshold' onChange={this.setTempMin.bind(this)} />
<Debounce />

If I remove value={this.props.temp.min}, it works perfectly.

fabimc avatar Mar 08 '17 22:03 fabimc

I also have an issue when setting the value to a prop. Debouncing works fine, but when the "props" value gets resetted to an empty string with a following re-render, the value in the box will still show the old one. When removing the <Debounce /> component I don't have the same issue.

Dhq avatar Mar 20 '17 08:03 Dhq

I'm having the same issue. When setting the input's value property, subsequent onChange events have the value set to the initial value of the input and not to the one I just set by typing something:

<Debounce time="400" handler="onChange">
  <input type="text"
         value={query}
         onChange={(e) => console.log(e.currentTarget.value)}
  />
</Debounce>

This works though:

<Debounce time="400" handler="onChange">
  <input type="text"
         // value={query}
         onChange={(e) => console.log(e.currentTarget.value)}
  />
</Debounce>

anler avatar Oct 07 '17 09:10 anler

same problem. I need to set an initial value to the field before modifying it. defaultValue kinda works but doesn't go well with input modifications by state.

lhtdesignde avatar Dec 01 '17 13:12 lhtdesignde

The same thing: doesn't work if the <input> contains "value" attribute.

angarsky avatar Aug 30 '19 12:08 angarsky