-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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(hooks): useProgress & usePlayback hooks #1723
Conversation
@puckey is there a way of accomplishing this that doesn't introduce a breaking change? |
@@ -131,7 +131,7 @@ export function useProgress(updateInterval = 1000) { | |||
return () => { | |||
mounted = false; | |||
}; | |||
}, [playerState, updateInterval]); | |||
}, [isNone, updateInterval]); | |||
|
|||
return state; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in this way, but there is slightly more convoluted way to fix this.. Will take a look at it later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@puckey please see the comment I left. I'd like to find a way to do this without a breaking change. As we'd need to hold off until the next major version if not.
I'm keen to see this fixed asap, so I'll share that @puckey and I were discussing this in the discord yesterday, and the initial fix proposed which worked without any breaking changes is mentioned here: |
- (breaking) fix: usePlaybackState was incorrectly returning State.None by default. Now it returns undefined while it is waiting on the async call to TrackPlayer to resolve. This also fixes the following issue where duration was incorrectly being reported as `0`: doublesymmetry#1709 - optimization: avoid unnecessarily reevaluating the useEffect on every player state change by moving the `playerState === State.None` outside of the effect and including it as a dependency instead
87b1cf9
to
b895b9c
Compare
How about something like this @jspizziri: b895b9c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@dcvz do you want to do a final approval on this one?
State.None
by default. Now it returns undefined while it is waiting on the async call to TrackPlayer to resolve. This also fixes the following issue where duration was incorrectly being reported as0
: Duration value is always '0' in useProgress hooks #1709playerState === State.None
outside of the effect and including it as a dependency instead