|
Download wp-calypso/packages/components/src/root-child/README.md from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 774 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/components/src/root-child/README.md
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/packages/components/src/root-child/README.md
-
curl -L -o README.md https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/components/src/root-child/README.md
774 Bytes
| # Root Child | |
| Root Child is a React component which will render its children as descendants | |
| of the root `<body>` element. This is handy in cases where you want to fix | |
| an element to the bounds of the page, without worrying that an ancestor | |
| positioning may impact the child's style. | |
| ## Usage | |
| ```jsx | |
| import { RootChild } from '@automattic/components'; | |
| export default function MyComponent() { | |
| return ( | |
| <div className="my-component"> | |
| <span>This text will be a child of MyComponent</span> | |
| <RootChild> | |
| <span>This text will be a child of the root element, not of MyComponent</span> | |
| </RootChild> | |
| </div> | |
| ); | |
| } | |
| ``` | |
| ## Notes | |
| The `<RootChild />` children are wrapped in a single `<div />` element, so they are not truly | |
| direct descendants of the `<body>` element. | |