uber / react-digraph

A library for creating directed graph editors
MIT License
2.62k stars 269 forks source link

Consider passing Node refs to calculateOffset somehow instead of using the DOM #258

Open ajbogh opened 4 years ago

ajbogh commented 4 years ago

Is your feature request related to a problem? Please describe. The calculateOffset edge function retrieves node elements from the DOM using IDs, but it would be much faster in theory, and perhaps safer, to pass the sourceNode and targetNode React elements using refs. This method would also survive server-side rendering since it wouldn't need document methods.

Describe the solution you'd like Modify the Edge component to accept sourceNodeRef and targetNodeRef. Pass those refs to the calculateOffset function and any other function that requires it. Use ref.current property to retrieve the DOM element for analysis.

Describe alternatives you've considered None