kdeloach / react-lineto

Draw a line between two elements in React
MIT License
234 stars 63 forks source link

Drawn lines not displaying correctly #39

Closed lema-fr closed 3 years ago

lema-fr commented 4 years ago

@kdeloach

Hello, I'm using react-lineto in my app to draw lines between elements, but when a page is rendered for the first time, lines are not displaying correctly, for example, should be a vertical line between B&C, but when the page loads for the first time, this line doesn't go from "B" to "C", it goes way up from "C" and displays correctly only if I refresh the page or change screen size. Could you please provide any tips on how to fix this?

Thank you.

AlanQuadros commented 4 years ago

Same problem

brianjychan commented 3 years ago

I had this problem, rendering the designated DOM elements, and then later rendering the worked for me. For instance, use a setTimeout to trigger the state change that adds the to the DOM

kdeloach commented 3 years ago

You can use the delay property to render lines after the target DOM elements are added. It uses setTimeout under the hood.