javdome / timeline-arrows

Class to easily draw lines to connect items in the vis Timeline module. See examples here: https://javdome.github.io/timeline-arrows/index.html
MIT License
42 stars 10 forks source link

How to integrate it with react ? #9

Closed ejabu closed 1 week ago

ejabu commented 2 months ago

How to integrate it with react ?

HugoBricoult commented 1 month ago

With react ref :

const Timeline = () => {

   const timelineRef = useRef();
   const arrowsRef = useRef();

   useEffect(()=>{
      const container = document.getElementById("timeline-id");
      timelineRef.current = new vis.Timeline(container, items, groups, options);
      arrowsRef.current = new Arrow(timelineRef.current, [])
   },[])

   return (
       <div id="timeline-id"/>
   )
}