File size: 774 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# 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.
|