@wordpress/data
Version:
Data module for WordPress.
8 lines (7 loc) • 1.66 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../../src/components/async-mode-provider/context.js"],
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nexport const Context = createContext( false );\nContext.displayName = 'AsyncModeContext';\n\nconst { Consumer, Provider } = Context;\n\nexport const AsyncModeConsumer = Consumer;\n\n/**\n * Context Provider Component used to switch the data module component rerendering\n * between Sync and Async modes.\n *\n * @example\n *\n * ```js\n * import { useSelect, AsyncModeProvider } from '@wordpress/data';\n * import { store as blockEditorStore } from '@wordpress/block-editor';\n *\n * function BlockCount() {\n * const count = useSelect( ( select ) => {\n * return select( blockEditorStore ).getBlockCount()\n * }, [] );\n *\n * return count;\n * }\n *\n * function App() {\n * return (\n * <AsyncModeProvider value={ true }>\n * <BlockCount />\n * </AsyncModeProvider>\n * );\n * }\n * ```\n *\n * In this example, the BlockCount component is rerendered asynchronously.\n * It means if a more critical task is being performed (like typing in an input),\n * the rerendering is delayed until the browser becomes IDLE.\n * It is possible to nest multiple levels of AsyncModeProvider to fine-tune the rendering behavior.\n *\n * @param {boolean} props.value Enable Async Mode.\n * @return {Component} The component to be rendered.\n */\nexport default Provider;\n"],
"mappings": ";AAGA,SAAS,qBAAqB;AAEvB,IAAM,UAAU,cAAe,KAAM;AAC5C,QAAQ,cAAc;AAEtB,IAAM,EAAE,UAAU,SAAS,IAAI;AAExB,IAAM,oBAAoB;AAqCjC,IAAO,kBAAQ;",
"names": []
}