uber / react-digraph

A library for creating directed graph editors
MIT License
2.63k stars 268 forks source link

Use shiftKey state from drag start in mousemove handlers #320

Closed ksnyder9801 closed 3 years ago

ksnyder9801 commented 3 years ago

Fixes #319

There are some really surprising interactions between D3 and useCallback here as a result of the functional component rewrite. https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback vs. https://github.com/d3/d3-drag/blob/v2.0.0/README.md#drag_on "Changes to registered listeners via drag.on during a drag gesture do not affect the current drag gesture"

The useRef approach here is "not recommended", but it's not clear to me if the recommended approach (useReducer at a much higher level) would be performant (in terms of re-renders) or even feasible without a massive rewrite.