Skip to content

Shared stores: expose store objects instead of store ID strings #49752

Description

@kraftbj

Background

The shared data stores (introduced in #49494) are consumed two ways today:

  • by the store object — the StoreDescriptor returned by createReduxStore — e.g. select( store ).getJetpackModules(); and
  • by the store ID string, e.g. select( JETPACK_MODULES_STORE_ID ) / useDispatch( JETPACK_MODULES_STORE_ID ).

Problem

Passing the store ID string to select() / useDispatch() loses the TypeScript types for the store's selectors and actions — the calls resolve to untyped data — and depending on the raw ID creates dependency issues.

In the review of #49494, @manzoorwanijk noted (on shared-extension-utils/src/hooks/use-module-status/index.js):

One of the goals for future would to not expose the store id, and rather expose the store object, which sets the TS types for the store selectors. Using store ID creates dependency issues.

Proposed work

  • Standardize on consuming the store object rather than the ID string, so selector and action types flow through to consumers.
  • Migrate the remaining ID-string consumers — e.g. useModuleStatus in shared-extension-utils still uses JETPACK_MODULES_STORE_ID with selectData( … ) / useDispatch( … ).

Follow-up to #49494.

Note: the store object only carries correct selector types when its @wordpress/data version matches the consumer's (see the alignment fix in #49494), so any consolidation should keep those versions in sync.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions