Perform debounce in React.js

前端 未结 30 1557
礼貌的吻别
礼貌的吻别 2020-11-22 04:11

How do you perform debounce in React.js?

I want to debounce the handleOnChange.

I tried with debounce(this.handleOnChange, 200) but it doesn\'t

30条回答
  •  终归单人心
    2020-11-22 04:34

    A nice and clean solution, that doesn't require any external dependencies:

    Debouncing with React Hooks

    It uses a custom plus the useEffect React hooks and the setTimeout / clearTimeout method.

提交回复
热议问题