Convert inner-block-layout-context to typescript (https://github.com/woocommerce/woocommerce-blocks/pull/9799)

* Convert inner-block-layout-context to typescript

* Add isLoading context
This commit is contained in:
Roy Ho 2023-06-14 06:36:39 -07:00 committed by GitHub
parent 524b95acbd
commit 6270c39de8
1 changed files with 10 additions and 8 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,
};