Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 6195e42

Browse files
authored
rename useQueryState to useQueryStateByContext (#1140)
this is more precise and removes ambuiguity about whether this returns React Context or not.
1 parent b7fddf7 commit 6195e42

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

assets/js/base/hooks/test/use-query-state.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { createRegistry, RegistryProvider } from '@wordpress/data';
88
* Internal dependencies
99
*/
1010
import {
11-
useQueryStateContext,
11+
useQueryStateByContext,
1212
useQueryStateByKey,
1313
useSynchronizedQueryState,
1414
} from '../use-query-state';
@@ -104,8 +104,8 @@ describe( 'Testing Query State Hooks', () => {
104104
},
105105
} );
106106
};
107-
describe( 'useQueryStateContext', () => {
108-
const TestComponent = getTestComponent( useQueryStateContext, [
107+
describe( 'useQueryStateByContext', () => {
108+
const TestComponent = getTestComponent( useQueryStateByContext, [
109109
'context',
110110
] );
111111
let renderer;

assets/js/base/hooks/use-query-state.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { useShallowEqual } from './use-shallow-equal';
1919
* query state value for the given context. The second element
2020
* is a dispatcher function for setting the query state.
2121
*/
22-
export const useQueryStateContext = ( context ) => {
22+
export const useQueryStateByContext = ( context ) => {
2323
const queryState = useSelect(
2424
( select ) => {
2525
const store = select( storeKey );
@@ -65,7 +65,7 @@ export const useQueryStateByKey = ( context, queryKey ) => {
6565
};
6666

6767
/**
68-
* A custom hook that works similarly to useQueryStateContext. However, this
68+
* A custom hook that works similarly to useQueryStateByContext. However, this
6969
* hook allows for synchronizing with a provided queryState object.
7070
*
7171
* This hook does the following things with the provided `synchronizedQuery`
@@ -90,7 +90,7 @@ export const useQueryStateByKey = ( context, queryKey ) => {
9090
* synchronize internal query state with.
9191
*/
9292
export const useSynchronizedQueryState = ( context, synchronizedQuery ) => {
93-
const [ queryState, setQueryState ] = useQueryStateContext( context );
93+
const [ queryState, setQueryState ] = useQueryStateByContext( context );
9494
const currentSynchronizedQuery = useShallowEqual( synchronizedQuery );
9595
// used to ensure we allow initial synchronization to occur before
9696
// returning non-synced state.

assets/js/blocks/price-filter/block.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import {
55
useCollection,
66
useQueryStateByKey,
7-
useQueryStateContext,
7+
useQueryStateByContext,
88
} from '@woocommerce/base-hooks';
99
import { useCallback } from '@wordpress/element';
1010

@@ -26,7 +26,7 @@ const PriceFilterBlock = ( { attributes } ) => {
2626
'product-grid',
2727
'max_price'
2828
);
29-
const [ queryState ] = useQueryStateContext( 'product-grid' );
29+
const [ queryState ] = useQueryStateByContext( 'product-grid' );
3030
const { results, isLoading } = useCollection( {
3131
namespace: '/wc/store',
3232
resourceName: 'products/collection-data',

0 commit comments

Comments
 (0)