@wordpress/data
Version:
Data module for WordPress.
28 lines • 1.19 kB
TypeScript
/**
* Internal dependencies
*/
import type { AnyConfig, CurriedSelectorsOf, StoreDescriptor } from './types';
/**
* Given a store descriptor, returns an object of the store's selectors.
* The selector functions are been pre-bound to pass the current state automatically.
* As a consumer, you need only pass arguments of the selector, if applicable.
*
* Warning: This global `select` function only works with the default registry.
* It will not work with custom `RegistryProvider` or `BlockEditorProvider` contexts.
* In React components, prefer the `useSelect` hook instead, which is registry-aware.
*
* @param storeNameOrDescriptor The store descriptor. The legacy calling convention
* of passing the store name is also supported.
*
* @example
* ```js
* import { select } from '@wordpress/data';
* import { store as myCustomStore } from 'my-custom-store';
*
* select( myCustomStore ).getPrice( 'hammer' );
* ```
*
* @return Object containing the store's selectors.
*/
export declare function select<T extends StoreDescriptor<AnyConfig>>(storeNameOrDescriptor: string | T): CurriedSelectorsOf<T>;
//# sourceMappingURL=select.d.ts.map