react-d3-graph icon indicating copy to clipboard operation
react-d3-graph copied to clipboard

UseEffect causes graph to not render properly

Open jadenmazzone opened this issue 4 years ago • 1 comments

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 avatar Jun 10 '21 23:06 jadenmazzone

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.

jadenmazzone avatar Jun 14 '21 16:06 jadenmazzone