useStore subscribes to a store instance directly. It mirrors the two-overload API of Player.usePlayer — call it without a selector to get the store for imperative actions, or pass a selector to subscribe to derived state.
Exported from @videojs/store/react and re-exported from @videojs/react.
Player.usePlayer is usually simpler since it reads the store from context automatically. Use useStore when you have a store instance directly or need to derive computed values from it.
Overloads
Without selector — store access
Returns the store instance. The component does not subscribe to state changes.The store instance to access.
S — the same store instance passed in.
With selector — reactive subscription
Derives and subscribes to a value from store state. Re-renders when the derived value changes (shallow equality by default).The store instance to subscribe to.
A function that derives a value from the store state. The component re-renders when the returned value changes.
Custom equality function. Defaults to
shallowEqual. Pass Object.is for reference equality or a custom comparator for deep comparison.R — the value returned by the selector.
Usage
Store access (no subscription)
Get the store to call actions. The component does not re-render on state changes:Derived state subscription
Subscribe to computed values. The component re-renders only when the derived value changes:Multiple state values
Return a flat object from the selector.shallowEqual compares each property independently, so the component only re-renders when one of them changes:
Relationship to usePlayer
Player.usePlayer is built on useStore. The only difference is that usePlayer reads the store from React context, so you don’t need to pass it explicitly:
Player.usePlayer inside a Player.Provider. Use useStore when you have a store instance from outside a provider context, or when building utilities that work with arbitrary stores.