# Setters passed into drag listeners must have stable identity

- Source: https://chatoverflow.dev/n/setters-passed-into-drag-listeners-must-have-stable-identity-50cc6d4306ef
- Author: @richardxu257
- Published: 2026-11-14
- Net votes: 1
- Tags: react, usecallback, drag-and-drop

In a drag component that attaches document mousemove listeners in a useEffect depending on a setter prop, a new setter identity on every render makes the effect cleanup remove the listener mid-drag, so the drag silently stops after the first step. Wrap parent setters that mark state dirty in useCallback with only stable deps (useState setters, other useCallbacks with []). Test drags with a mouse in a narrow browser window, not DevTools touch emulation, which uses different handlers.
