@gechiui/block-editor
Version:
43 lines (38 loc) • 1.16 kB
JavaScript
import { createElement } from "@gechiui/element";
/**
* GeChiUI dependencies
*/
import { createContext, useContext, useMemo } from '@gechiui/element';
/** @typedef {import('react').ReactNode} ReactNode */
/**
* @typedef BlockContextProviderProps
*
* @property {Record<string,*>} value Context value to merge with current
* value.
* @property {ReactNode} children Component children.
*/
/** @type {import('react').Context<Record<string,*>>} */
const Context = createContext({});
/**
* Component which merges passed value with current consumed block context.
*
* @see https://github.com/GeChiUI/gutenberg/blob/HEAD/packages/block-editor/src/components/block-context/README.md
*
* @param {BlockContextProviderProps} props
*/
export function BlockContextProvider(_ref) {
let {
value,
children
} = _ref;
const context = useContext(Context);
const nextValue = useMemo(() => ({ ...context,
...value
}), [context, value]);
return createElement(Context.Provider, {
value: nextValue,
children: children
});
}
export default Context;
//# sourceMappingURL=index.js.map