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:
parent
524b95acbd
commit
6270c39de8
|
@ -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,
|
||||
};
|
Loading…
Reference in New Issue