30秒学会 React 片段 – React useEventListener hook
Adds an event listener for the specified event type on the given element. Use the useRef() hook to c...
Adds an event listener for the specified event type on the given element. Use the useRef() hook to c...
Watches for changes made to the DOM tree, using a MutationObserver Use a useEffect() hook that depen...
Executes a callback immediately after a component is updated. Use the useRef() hook to create a vari...
Executes a callback whenever the window is scrolled. Use the useRef() hook to create a variable, lis...
Returns a stateful value, persisted in localStorage, and a function to update it. Use the useState()...
Executes a callback whenever the window is resized. Use the useRef() hook to create a variable, list...
Delays creating a stateful value until some condition is met. Use the useState() hook to create a st...
Tracks the dimensions of the browser window. Use the useState() hook to initialize a state variable ...
Handles the beforeunload window event. Use the useRef() hook to create a ref for the callback functi...
Debounces the given value. Create a custom hook that takes a value and a delay. Use the useState() h...