Skip to content

docs(react): clarify usePlayer typed vs untyped store access#1663

Open
Jerricho93 wants to merge 1 commit into
videojs:mainfrom
Jerricho93:docs/1483-use-player-typing
Open

docs(react): clarify usePlayer typed vs untyped store access#1663
Jerricho93 wants to merge 1 commit into
videojs:mainfrom
Jerricho93:docs/1483-use-player-typing

Conversation

@Jerricho93

@Jerricho93 Jerricho93 commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

Closes #1483

Summary

The use-player reference page mentioned the typed-vs-untyped distinction only in a single easy-to-miss sentence, so users assumed the standalone usePlayer() is supposed to return unknown. This makes the distinction prominent on the page and corrects the standalone hook's generated reference.

Changes

  • Add a note callout to the use-player reference page: Player.usePlayer (from createPlayer) is typed to the configured features and needs no selector, while the standalone import { usePlayer } returns an untyped UnknownStore and needs a premade selector to recover typing.
  • Enrich the standalone usePlayer JSDoc so the generated reference explains the UnknownStore return — and that inline selectors stay unknown while premade selectors (e.g. selectPlayback) carry their type.

Testing

  • pnpm -F site api-docs — regenerates the util reference; confirmed use-player.json now includes the new JSDoc paragraphs.
  • pnpm build:site — site builds and the page renders.

Related: #1111 (premade selectors incompatible with createPlayer().PlayerController types) is a separate types bug and is not addressed here.


Note

Low Risk
Documentation and JSDoc only; no runtime or type behavior changes.

Overview
Improves discoverability of typed vs. untyped usePlayer behavior so users don’t treat standalone unknown returns as a bug.

The use-player reference adds a note callout and a short example: Player.usePlayer from createPlayer() is feature-typed without a selector; standalone import { usePlayer } from '@videojs/react' yields an UnknownStore, with typing recoverable via premade selectors like selectPlayback.

JSDoc on the standalone usePlayer overloads now states the same — no feature knowledge, UnknownStore / UnknownState, inline selectors stay unknown, premade selectors carry their return type — so generated API reference matches the docs page.

Reviewed by Cursor Bugbot for commit 8c447e2. Bugbot is set up for automated code reviews on this repo. Configure here.

Add a note callout on the use-player reference page contrasting the typed
Player.usePlayer (from createPlayer) with the untyped standalone usePlayer,
and enrich the standalone hook's JSDoc so the generated reference explains
the UnknownStore return and selector-based typing.

Refs videojs#1483
@netlify

netlify Bot commented Jun 5, 2026

Copy link
Copy Markdown

👷 Deploy request for vjs10-site pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 8c447e2

@vercel

vercel Bot commented Jun 5, 2026

Copy link
Copy Markdown

@Jerricho93 is attempting to deploy a commit to the Mux Team on Vercel.

A member of the Team first needs to authorize it.

@Jerricho93 Jerricho93 marked this pull request as ready for review June 8, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Docs: usePlayer() Return Type Is Unclear — Selector Required for Typed Access

1 participant