woocommerce/plugins/woocommerce-blocks/assets/js/data/query-state
Alex Florisca c52dc91f67 Update from deprecated registerStore to register for data stores (https://github.com/woocommerce/woocommerce-blocks/pull/7310)
* Update from deprecated registerStore to register for data stores

* Rollback cart changes

* bot: update checkstyle.xml

* Explain keeping the deprecated "registerStore"

Co-authored-by: Tarun Vijwani <tarun.vijwani@automattic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-11-10 15:37:01 +00:00
..
test Reorder dependencies (https://github.com/woocommerce/woocommerce-blocks/pull/2774) 2020-06-26 13:01:35 +01:00
README.md Improve the structure of the WooCommerce Blocks Handbook (https://github.com/woocommerce/woocommerce-blocks/pull/6429) 2022-06-09 17:52:19 +02:00
action-types.js All Products with Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/1032) 2019-10-28 09:53:09 -04:00
actions.js All Products with Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/1032) 2019-10-28 09:53:09 -04:00
constants.js Remove v1 from Store Keys (https://github.com/woocommerce/woocommerce-blocks/pull/5987) 2022-03-04 14:03:52 +00:00
index.js Update from deprecated registerStore to register for data stores (https://github.com/woocommerce/woocommerce-blocks/pull/7310) 2022-11-10 15:37:01 +00:00
reducers.js don’t mutate default state constant. (https://github.com/woocommerce/woocommerce-blocks/pull/1245) 2019-11-22 15:18:45 -05:00
selectors.js Update @woocmmerce/eslint-plugin to 2.0.0 (https://github.com/woocommerce/woocommerce-blocks/pull/6203) 2022-04-08 14:47:19 +01:00
utils.js All Products with Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/1032) 2019-10-28 09:53:09 -04:00

README.md

Query State Store

Table of contents

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:

import { QUERY_STATE_STORE_KEY } from '@woocommerce/block-data';

Actions

The following actions are used for dispatching data to this store state.

Note:: New values will always overwrite any existing entry in the store.

setQueryValue( context, queryKey, value )

This will set a single query-state value for a given context.

Argument Type Description
context string The context for the query state being stored (eg. might be a 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.

setValueForQueryContext( context, value )

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.

Argument Type Description
context string The context for the query state being stored (eg. might be a 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.