Function not correctly reading updated state from React hook state
问题 I was trying to implement a simple paint component with React hooks. My expected behavior was 'mouseMove' to be executed when I moved my mouse while remaining clicked. However, state.isMouseDown always returned false within mouseMove(). Any fixes or references to potentially helpful documents would be grateful. const initialState = { isMouseDown: false, isMouseMoving: false }; const DrawingCanvas = () => { const [state, setState] = useState(initialState); useEffect(() => { console.log(