The documentation for WooCommerce Blocks has moved to the WooCommerce monorepo.
Please refer to the documentation in the new location as the files in this repository will no longer be updated and the repository will be archived.
The Query State Store offers actions to handle and manipulate query-related data within specific contexts, such as individual blocks. This facilitates the dynamic updating and retrieval of query-state values, ensuring accurate and context-specific data management within WooCommerce Blocks.
To utilize this store you will import the QUERY_STATE_STORE_KEY
in any module referencing it. Assuming @woocommerce/block-data
is registered as an external pointing to wc.wcBlocksData
you can import the key via:
const { QUERY_STATE_STORE_KEY } = window.wc.wcBlocksData;
⚠️ New values will always overwrite any existing entry in the store.
This will set a single query-state value for a given context.
- context
string
: The context for the query state being stored, eg. the block name so you can keep query-state specific per block. - queryKey
string
: The reference for the value being stored. - value
mixed
: The actual value being stored for the query-state.
This will set the query-state for a given context. Typically this is used to set/replace the entire query-state for a given context rather than the individual keys for the context via setQueryValue
.
- context
string
: The context for the query state being stored, eg. the block name so you can keep query-state specific per block. - value
object
: An object of key/value pairs for the query state being attached to the context.
We're hiring! Come work with us!
🐞 Found a mistake, or have a suggestion? Leave feedback about this document here.