showing results for - "how to add debounce in react redux js"
Jesús
03 Jul 2019
1function SearchInput() {
2  const [realTimeValue, setRealTimeValue] = useState('');
3
4  const debouncedValue = useDebouncedValue(realTimeValue, 500); // this value will pick real time value, but will change it's result only when it's seattled for 500ms
5
6  useEffect(() => {
7    // this effect will be called on seattled values
8    api.fetchSearchResults(debouncedValue);
9  }, [debouncedValue])
10
11  return <input onChange={event => setRealTimeValue(event.target.value)} />
12}
13