Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: store timeframe ref in useState #51

Merged
merged 1 commit into from
Aug 23, 2024
Merged

fix: store timeframe ref in useState #51

merged 1 commit into from
Aug 23, 2024

Conversation

samuelarbibe
Copy link
Owner

The timeframe ref is used internally and externally to perform all kinds of calculations, and to trigger width and direction updates according to the timeframe element if needed.

The problem

The current the ref is saved using a useRef, meaning there is no way to detect changes in the ref after an unmount.
This may be needed in situations where the timeline is mounted and unmounted in loading states.
When re-mounted, many listeners will no-longer work.

The solution

The timeline ref is now saved in a useState, and changes to that state can be easily listened to by any event listener, useEffect, useCallback etc.
The timeline ref is now a part of the conventional react lifecycle.

Copy link

vercel bot commented Aug 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
dnd-timeline-external ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 23, 2024 11:20am
dnd-timeline-sortable ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 23, 2024 11:20am
dnd-timeline-virtual ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 23, 2024 11:20am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant