mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 14:57:26 +08:00
25 lines
774 B
JavaScript
25 lines
774 B
JavaScript
/**
|
|
* Selectors: Extract specific pieces of state from the store.
|
|
*
|
|
* These functions provide a consistent interface for accessing store data.
|
|
* They allow components to retrieve data without knowing the store structure.
|
|
*
|
|
* @file
|
|
*/
|
|
|
|
const EMPTY_OBJ = Object.freeze( {} );
|
|
|
|
const getState = ( state ) => state || EMPTY_OBJ;
|
|
|
|
export const persistentData = ( state ) => {
|
|
return getState( state ).data || EMPTY_OBJ;
|
|
};
|
|
|
|
export const transientData = ( state ) => {
|
|
const { data, wooSettings, ...transientState } = getState( state ); // ← extract the wooSettings, to ensure they are not part of the "transientState" collection.
|
|
return transientState || EMPTY_OBJ;
|
|
};
|
|
|
|
export const wooSettings = ( state ) => {
|
|
return getState( state ).wooSettings || EMPTY_OBJ;
|
|
};
|