mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-07 19:54:15 +08:00
🚚 Rename Redux store (settings-tab → settings)
This commit is contained in:
parent
664e81d5c3
commit
e2f88cdef8
10 changed files with 1 additions and 1 deletions
43
modules/ppcp-settings/resources/js/data/settings/hooks.js
Normal file
43
modules/ppcp-settings/resources/js/data/settings/hooks.js
Normal file
|
@ -0,0 +1,43 @@
|
|||
/**
|
||||
* Hooks: Provide the main API for components to interact with the store.
|
||||
*
|
||||
* These encapsulate store interactions, offering a consistent interface.
|
||||
* Hooks simplify data access and manipulation for components.
|
||||
*
|
||||
* @file
|
||||
*/
|
||||
import { useDispatch } from '@wordpress/data';
|
||||
|
||||
import { STORE_NAME } from './constants';
|
||||
import { createHooksForStore } from '../utils';
|
||||
|
||||
const useHooks = () => {
|
||||
const { useTransient, usePersistent } = createHooksForStore( STORE_NAME );
|
||||
const { persist } = useDispatch( STORE_NAME );
|
||||
|
||||
// Read-only flags and derived state.
|
||||
const [ isReady ] = useTransient( 'isReady' );
|
||||
|
||||
// Persistent accessors.
|
||||
const [ settings, setSettings ] = usePersistent( 'settings' );
|
||||
|
||||
return {
|
||||
persist,
|
||||
isReady,
|
||||
settings,
|
||||
setSettings,
|
||||
};
|
||||
};
|
||||
|
||||
export const useStore = () => {
|
||||
const { persist, isReady } = useHooks();
|
||||
return { persist, isReady };
|
||||
};
|
||||
|
||||
export const useSettings = () => {
|
||||
const { settings, setSettings } = useHooks();
|
||||
return {
|
||||
settings,
|
||||
setSettings,
|
||||
};
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue