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

Add React utility hooks #51

Merged
merged 10 commits into from
Feb 14, 2024
Merged

Add React utility hooks #51

merged 10 commits into from
Feb 14, 2024

Conversation

MattiasBuelens
Copy link
Collaborator

This adds hooks such as useCurrentTime(), usePaused() and useVolume(), to easily access the player's state from within a custom React component.

I also reworked our internals to avoid useEffect() as much as possible, using the techniques from You Might Not Need an Effect.

  • Adding/removing event listeners now uses useSyncExternalStore.
  • usePlayer() now accepts the UI element as a prop, rather than returning a setUi callback.

@MattiasBuelens MattiasBuelens added the enhancement New feature or request label Feb 14, 2024
@MattiasBuelens MattiasBuelens merged commit 7997aa8 into main Feb 14, 2024
1 check passed
@MattiasBuelens MattiasBuelens deleted the react-utility-hooks branch February 14, 2024 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants