|
Download wp-calypso/packages/block-renderer/README.md from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.14 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/block-renderer/README.md
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/packages/block-renderer/README.md
-
curl -L -o README.md https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/block-renderer/README.md
1.14 kB
| # Block Renderer | |
| Render blocks on the client side | |
| ## Usage | |
| ```jsx | |
| import { | |
| BlockRendererProvider, | |
| PatternsRendererProvider, | |
| PatternRenderer, | |
| } from '@automattic/block-renderer'; | |
| const PatternsPreview = () => ( | |
| <BlockRendererProvider siteId={ siteId } stylesheet={ stylesheet }> | |
| <PatternsRendererProvider siteId={ siteId } stylesheet={ stylesheet } patternIds={ patternIds }> | |
| <PatternRenderer patternId={ patternId } /> | |
| </PatternsRendererProvider> | |
| </BlockRendererProvider> | |
| ); | |
| ``` | |
| ## Components | |
| ### BlockRendererProvider | |
| Initialize the settings of the block renderer. It will fetch the settings from an endpoint and store them in the `blockEditorStore` | |
| ### BlockRendererContainer | |
| Render the iframe to control the styles of block, and you can pass any blocks you want to render to its children | |
| ### PatternsRendererProvider | |
| Initialize the provided pattern ids. It will fetch the rendered html of each pattern, and store them in the `PatternsRendererContext`. | |
| Note that it fetches 20 patterns per request to avoid any potential performance issues. | |
| ### PatternRenderer | |
| Render the pattern by the provided pattern id. | |