docs(readme): document how to reach the player API from a ref - #39
Open
jwbrandon wants to merge 2 commits into
Open
docs(readme): document how to reach the player API from a ref#39jwbrandon wants to merge 2 commits into
jwbrandon wants to merge 2 commits into
Conversation
The component already exposes the player instance on its ref, but the README only mentioned `this.player`, so consumers had no documented way to get the API and reached for workarounds. Document both routes — ref and didMountCallback — and spell out the two cases where `ref.current.player` is null: before the library resolves, and after unmount. Add tests covering that contract. Closes #31
Review caught three inaccuracies in the new section. The claim that all callbacks are safe was wrong: componentWillUnmount invokes willUnmountCallback before the player guard, so its player argument can be null, which the shipped types already stated. A failed library load is a third, permanent null case. The useEffect timing claim only holds when the library loads over the network, so soften it to "may". The pending-load test could not fail, because a null window.jwplayer blocks setup no matter what the component does. Assert the transition to a live player instead. Also make the didMountCallback example a complete component so it can be copy-pasted.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Documents how to reach the player API from a ref (
ref.current.player), which already worked but was undocumented, so consumers improvised workarounds. Adds adidMountCallbackexample alongside it, spells out the two cases whereref.current.playeris null — before the library resolves and after unmount — and adds three tests covering that contract.Closes #31