Skip to content

docs(readme): document how to reach the player API from a ref - #39

Open
jwbrandon wants to merge 2 commits into
mainfrom
docs/player-ref
Open

docs(readme): document how to reach the player API from a ref#39
jwbrandon wants to merge 2 commits into
mainfrom
docs/player-ref

Conversation

@jwbrandon

Copy link
Copy Markdown
Contributor

Documents how to reach the player API from a ref (ref.current.player), which already worked but was undocumented, so consumers improvised workarounds. Adds a didMountCallback example alongside it, spells out the two cases where ref.current.player is null — before the library resolves and after unmount — and adds three tests covering that contract.

Closes #31

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.
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.

Ref???

1 participant