danielcaldas / react-d3-graph

Interactive and configurable graphs with react and d3 effortlessly
https://danielcaldas.github.io/react-d3-graph/sandbox/
MIT License
819 stars 233 forks source link

UseEffect causes graph to not render properly #473

Open jadenmazzone opened 3 years ago

jadenmazzone commented 3 years ago

Describe the bug When setting a state variable in a useEffect causes the graph to not render properly.

To Reproduce Steps to reproduce the behavior:

  1. write a useEffect with a "setState" in it, in the same function where the Graph is being rendered.

Expected behavior The graph rendering should not be affected by changing the state of a variable that doesn't have anything to do with the graph.

Screenshots If applicable, add screenshots to help explain your problem.

(1)

Screen Shot 2021-06-10 at 1 57 54 PM

(2)

Screen Shot 2021-06-10 at 1 58 05 PM

(1) Screen Shot 2021-06-10 at 1 56 19 PM (2) Screen Shot 2021-06-10 at 1 55 47 PM

Environment:

OS: macOS Browser: chrome Version: 90 Node version: 14.15.4 react-d3-graph version: 2.6.0 d3 version: 5.16.0 react version: 16.13.1

Additional context Add any other context about the problem here.

jadenmazzone commented 3 years ago

This is actually the same issue as: https://github.com/danielcaldas/react-d3-graph/issues/472. Essentially, if d3 is set in the config and the graph is non-static, any state change will change the positions of the nodes on the graph.