xyflow / xyflow

React Flow | Svelte Flow - Powerful open source libraries for building node-based UIs with React (https://reactflow.dev) or Svelte (https://svelteflow.dev). Ready out-of-the-box and infinitely customizable.
https://xyflow.com
MIT License
21.84k stars 1.45k forks source link

useOnSelectionChange on change must be memoized now #4273

Open jroith opened 3 weeks ago

jroith commented 3 weeks ago

Describe the Bug

The on change callback must be memoized using useCallback now. Otherwise the event triggers only when deselecting a node.

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

  1. Pass an onChange function to useOnSelectionChange that has not been wrapped in useCallback.
  2. Observe that the event only triggers when deselecting a node.

Expected behavior

This should be documented as a breaking change or fixed.

Screenshots or Videos

No response

Platform

Additional context

No response