UNPKG

@wordpress/data

Version:
8 lines (7 loc) 1.84 kB
{ "version": 3, "sources": ["../../../src/components/registry-provider/context.js"], "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport defaultRegistry from '../../default-registry';\n\nexport const Context = createContext( defaultRegistry );\nContext.displayName = 'RegistryProviderContext';\n\nconst { Consumer, Provider } = Context;\n\n/**\n * A custom react Context consumer exposing the provided `registry` to\n * children components. Used along with the RegistryProvider.\n *\n * You can read more about the react context api here:\n * https://react.dev/learn/passing-data-deeply-with-context#step-3-provide-the-context\n *\n * @example\n * ```js\n * import {\n * RegistryProvider,\n * RegistryConsumer,\n * createRegistry\n * } from '@wordpress/data';\n *\n * const registry = createRegistry( {} );\n *\n * const App = ( { props } ) => {\n * return <RegistryProvider value={ registry }>\n * <div>Hello There</div>\n * <RegistryConsumer>\n * { ( registry ) => (\n * <ComponentUsingRegistry\n * \t\t{ ...props }\n * \t registry={ registry }\n * ) }\n * </RegistryConsumer>\n * </RegistryProvider>\n * }\n * ```\n */\nexport const RegistryConsumer = Consumer;\n\n/**\n * A custom Context provider for exposing the provided `registry` to children\n * components via a consumer.\n *\n * See <a name=\"#RegistryConsumer\">RegistryConsumer</a> documentation for\n * example.\n */\nexport default Provider;\n"], "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA8B;AAK9B,8BAA4B;AAErB,IAAM,cAAU,8BAAe,wBAAAA,OAAgB;AACtD,QAAQ,cAAc;AAEtB,IAAM,EAAE,UAAU,SAAS,IAAI;AAiCxB,IAAM,mBAAmB;AAShC,IAAO,kBAAQ;", "names": ["defaultRegistry"] }