rebase on oct-10-2023

This commit is contained in:
Rachit Bhargava
2023-10-10 17:23:21 -04:00
parent d37566ffb6
commit d096058d7d
4789 changed files with 254611 additions and 307223 deletions

View File

@@ -1,7 +1,6 @@
/**
* External dependencies
*/
import PropTypes from 'prop-types';
import { createContext, useContext } from '@wordpress/element';
/**
@@ -20,14 +19,23 @@ const InnerBlockLayoutContext = createContext( {
export const useInnerBlockLayoutContext = () =>
useContext( InnerBlockLayoutContext );
interface InnerBlockLayoutContextProviderProps {
parentName?: string;
parentClassName?: string;
isLoading?: boolean;
children: React.ReactNode;
}
export const InnerBlockLayoutContextProvider = ( {
parentName = '',
parentClassName = '',
isLoading = false,
children,
} ) => {
}: InnerBlockLayoutContextProviderProps ) => {
const contextValue = {
parentName,
parentClassName,
isLoading,
};
return (
<InnerBlockLayoutContext.Provider value={ contextValue }>
@@ -35,9 +43,3 @@ export const InnerBlockLayoutContextProvider = ( {
</InnerBlockLayoutContext.Provider>
);
};
InnerBlockLayoutContextProvider.propTypes = {
children: PropTypes.node,
parentName: PropTypes.string,
parentClassName: PropTypes.string,
};

View File

@@ -7,6 +7,9 @@ import {
useProductDataContext,
} from '@woocommerce/shared-context';
const getProductById = ( products, id ) =>
products.find( ( product ) => product.id === id );
/**
* Loads the product from the API and adds to the context provider.
*
@@ -22,7 +25,10 @@ const OriginalComponentWithContext = ( props ) => {
} );
const productFromAPI = {
product: id > 0 && products.length > 0 ? products[ 0 ] : null,
product:
id > 0 && products.length > 0
? getProductById( products, id )
: null,
isLoading: productsLoading,
};