UNPKG

@wordpress/core-data

Version:
23 lines (22 loc) 649 B
// packages/core-data/src/entity-provider.js import { useContext, useMemo } from "@wordpress/element"; import { EntityContext } from "./entity-context"; import { jsx } from "react/jsx-runtime"; function EntityProvider({ kind, type: name, id, children }) { const parent = useContext(EntityContext); const childContext = useMemo( () => ({ ...parent, [kind]: { ...parent?.[kind], [name]: id } }), [parent, kind, name, id] ); return /* @__PURE__ */ jsx(EntityContext.Provider, { value: childContext, children }); } export { EntityProvider as default }; //# sourceMappingURL=entity-provider.js.map