react-vis-timeline
react-vis-timeline copied to clipboard
There is no way to update the items as it only takes in the initialItems
Overview
We dynamically change the items but here the items are initial only? Was that intentional?
Package versions
react-vis-timeline: 2.0.3 vis version: 4.21.0
Steps to reproduce
Add step by step guide to reproduce issue
- Creating the timeline sending in initialItems and initialGroups
- Items were updated but the timeline stays the same
Code Snippet
<Timeline
options={timelineOptions}
ref={timelineRef}
initialItems={timelineItems}
initialGroups={updatedGroups}
rangechangeHandler={rangeChangeHandler}
/>
Related issues
Any issue which is related to this issue
- e.g. issue 123
Screenshots (if appropriate)
what i did was instead of adding the items in initialItems I added them in a useEffect: useEffect( () => { if (timelineRef.current.timeline) { timelineRef.current.timeline.setItems(timelineItems); } }, [timelineItems] );
what i did was instead of adding the items in initialItems I added them in a useEffect: useEffect( () => { if (timelineRef.current.timeline) { timelineRef.current.timeline.setItems(timelineItems); } }, [timelineItems] );
Yes, your mehod is correct for changing the items.
initialItems is exists for more like static situations, when you have all data before and just want to display it once.
I know it can be confusing - two ways for passing data. So I works on next version, which uses only react props, but also good at performance by using vis's native api.