mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
✨ Move prop “location” into Redux store
This commit is contained in:
parent
209b7a7c88
commit
0673e5d813
2 changed files with 5 additions and 1 deletions
|
@ -30,6 +30,7 @@ const useHooks = () => {
|
|||
|
||||
// Transient accessors.
|
||||
const [ isReady ] = useTransient( 'isReady' );
|
||||
const [ location, setLocation ] = useTransient( 'location' );
|
||||
|
||||
// Persistent accessors.
|
||||
const [ shape, setShape ] = usePersistent( 'shape' );
|
||||
|
@ -37,6 +38,8 @@ const useHooks = () => {
|
|||
return {
|
||||
persist,
|
||||
isReady,
|
||||
location,
|
||||
setLocation,
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -46,7 +49,7 @@ export const useStore = () => {
|
|||
};
|
||||
|
||||
export const useStylingLocation = () => {
|
||||
const [ location, setLocation ] = useState( 'cart' );
|
||||
const { location, setLocation } = useHooks();
|
||||
return { location, setLocation };
|
||||
};
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import { STYLING_COLORS, STYLING_SHAPES } from './configuration';
|
|||
// Transient: Values that are _not_ saved to the DB (like app lifecycle-flags).
|
||||
const defaultTransient = Object.freeze( {
|
||||
isReady: false,
|
||||
location: 'cart', // Which location is selected in the Styling tab.
|
||||
} );
|
||||
|
||||
// Persistent: Values that are loaded from the DB.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue