Answers for "onchange debounce react"

1

onchange debounce react

import React, { useCallback } from 'react';
import _ from 'lodash';

const MyComponent = ({ data, handleInputChange }) => {
  const debounceFunc = useCallback(
    _.debounce(e => handleInputChange(e), 500),
    []
  );

  const handleChange = e => {
    debounceFunc(e);
  };
  return <TextInput data={data} onChange={handleChange} />;
};

export default MyComponent;
Posted by: Guest on October-16-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language