UNPKG

@wordpress/block-editor

Version:
48 lines (43 loc) 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BlockContextProvider = BlockContextProvider; exports.default = void 0; var _element = require("@wordpress/element"); var _jsxRuntime = require("react/jsx-runtime"); /** * WordPress dependencies */ /** @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 = (0, _element.createContext)({}); /** * Component which merges passed value with current consumed block context. * * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-context/README.md * * @param {BlockContextProviderProps} props */ function BlockContextProvider({ value, children }) { const context = (0, _element.useContext)(Context); const nextValue = (0, _element.useMemo)(() => ({ ...context, ...value }), [context, value]); return /*#__PURE__*/(0, _jsxRuntime.jsx)(Context.Provider, { value: nextValue, children: children }); } var _default = exports.default = Context; //# sourceMappingURL=index.js.map