// wrap the callback with React.useCallback const handleChange = useCallback(() => { setState(state + 1); },[]);