Skip to content

Commit

Permalink
Allow dependent applications to programmatically set the current inde…
Browse files Browse the repository at this point in the history
…x (#320)

As requested in prabhuignoto/react-chrono#300
(and also because I needed it 😄), this implements a simple `useEffect`
that updates the `activeTimelineIndex` accordingly.
  • Loading branch information
tony43e committed Feb 2, 2023
1 parent 6ba5570 commit bd6e6b3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ const Chrono: React.FunctionComponent<Partial<TimelineProps>> = (
}
}, []);

useEffect(() => {
handleTimelineUpdate(activeItemIndex);
}, [activeItemIndex]);

const restartSlideShow = useCallback(() => {
setSlideshowActive(true);
handleTimelineUpdate(0);
Expand Down

0 comments on commit bd6e6b3

Please sign in to comment.