Skip to content

Commit d56a7bc

Browse files
committed
docs(reference): capitalize Portal as a React concept
Use "Portal" consistently in reference docs when referring to the createPortal feature, matching how other React concepts are written.
1 parent 6ec6134 commit d56a7bc

7 files changed

Lines changed: 23 additions & 23 deletions

File tree

src/content/reference/react-dom/client/createRoot.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ function Counter() {
199199
200200
**If your app is fully built with React, you shouldn't need to create any more roots, or to call [`root.render`](#root-render) again.**
201201
202-
From this point on, React will manage the DOM of your entire app. To add more components, [nest them inside the `App` component.](/learn/importing-and-exporting-components) When you need to update the UI, each of your components can do this by [using state.](/reference/react/useState) When you need to display extra content like a modal or a tooltip outside the DOM node, [render it with a portal.](/reference/react-dom/createPortal)
202+
From this point on, React will manage the DOM of your entire app. To add more components, [nest them inside the `App` component.](/learn/importing-and-exporting-components) When you need to update the UI, each of your components can do this by [using state.](/reference/react/useState) When you need to display extra content like a modal or a tooltip outside the DOM node, [render it with a Portal.](/reference/react-dom/createPortal)
203203
204204
<Note>
205205

src/content/reference/react-dom/components/common.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ All built-in browser components, such as [`<div>`](https://developer.mozilla.org
2626

2727
These special React props are supported for all built-in components:
2828

29-
* `children`: A React node (an element, a string, a number, [a portal,](/reference/react-dom/createPortal) an empty node like `null`, `undefined` and booleans, or an array of other React nodes). Specifies the content inside the component. When you use JSX, you will usually specify the `children` prop implicitly by nesting tags like `<div><span /></div>`.
29+
* `children`: A React node (an element, a string, a number, [a Portal,](/reference/react-dom/createPortal) an empty node like `null`, `undefined` and booleans, or an array of other React nodes). Specifies the content inside the component. When you use JSX, you will usually specify the `children` prop implicitly by nesting tags like `<div><span /></div>`.
3030

3131
* `dangerouslySetInnerHTML`: An object of the form `{ __html: '<p>some html</p>' }` with a raw HTML string inside. Overrides the [`innerHTML`](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML) property of the DOM node and displays the passed HTML inside. This should be used with extreme caution! If the HTML inside isn't trusted (for example, if it's based on user data), you risk introducing an [XSS](https://en.wikipedia.org/wiki/Cross-site_scripting) vulnerability. [Read more about using `dangerouslySetInnerHTML`.](#dangerously-setting-the-inner-html)
3232

src/content/reference/react-dom/createPortal.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ title: createPortal
2424
2525
### `createPortal(children, domNode, key?)` {/*createportal*/}
2626
27-
To create a portal, call `createPortal`, passing some JSX, and the DOM node where it should be rendered:
27+
To create a Portal, call `createPortal`, passing some JSX, and the DOM node where it should be rendered:
2828
2929
```js
3030
import { createPortal } from 'react-dom';
@@ -42,23 +42,23 @@ import { createPortal } from 'react-dom';
4242
4343
[See more examples below.](#usage)
4444
45-
A portal only changes the physical placement of the DOM node. In every other way, the JSX you render into a portal acts as a child node of the React component that renders it. For example, the child can access the context provided by the parent tree, and events bubble up from children to parents according to the React tree.
45+
A Portal only changes the physical placement of the DOM node. In every other way, the JSX you render into a Portal acts as a child node of the React component that renders it. For example, the child can access the context provided by the parent tree, and events bubble up from children to parents according to the React tree.
4646
4747
#### Parameters {/*parameters*/}
4848
4949
* `children`: Anything that can be rendered with React, such as a piece of JSX (e.g. `<div />` or `<SomeComponent />`), a [Fragment](/reference/react/Fragment) (`<>...</>`), a string or a number, or an array of these.
5050
51-
* `domNode`: Some DOM node, such as those returned by `document.getElementById()`. The node must already exist. Passing a different DOM node during an update will cause the portal content to be recreated.
51+
* `domNode`: Some DOM node, such as those returned by `document.getElementById()`. The node must already exist. Passing a different DOM node during an update will cause the Portal content to be recreated.
5252
53-
* **optional** `key`: A unique string or number to be used as the portal's [key.](/learn/rendering-lists#keeping-list-items-in-order-with-key)
53+
* **optional** `key`: A unique string or number to be used as the Portal's [key.](/learn/rendering-lists#keeping-list-items-in-order-with-key)
5454
5555
#### Returns {/*returns*/}
5656
5757
`createPortal` returns a React node that can be included into JSX or returned from a React component. If React encounters it in the render output, it will place the provided `children` inside the provided `domNode`.
5858
5959
#### Caveats {/*caveats*/}
6060
61-
* Events from portals propagate according to the React tree rather than the DOM tree. For example, if you click inside a portal, and the portal is wrapped in `<div onClick>`, that `onClick` handler will fire. If this causes issues, either stop the event propagation from inside the portal, or move the portal itself up in the React tree.
61+
* Events from Portals propagate according to the React tree rather than the DOM tree. For example, if you click inside a Portal, and the Portal is wrapped in `<div onClick>`, that `onClick` handler will fire. If this causes issues, either stop the event propagation from inside the Portal, or move the Portal itself up in the React tree.
6262
6363
---
6464
@@ -68,7 +68,7 @@ A portal only changes the physical placement of the DOM node. In every other way
6868
6969
*Portals* let your components render some of their children into a different place in the DOM. This lets a part of your component "escape" from whatever containers it may be in. For example, a component can display a modal dialog or a tooltip that appears above and outside of the rest of the page.
7070
71-
To create a portal, render the result of `createPortal` with <CodeStep step={1}>some JSX</CodeStep> and the <CodeStep step={2}>DOM node where it should go</CodeStep>:
71+
To create a Portal, render the result of `createPortal` with <CodeStep step={1}>some JSX</CodeStep> and the <CodeStep step={2}>DOM node where it should go</CodeStep>:
7272
7373
```js [[1, 8, "<p>This child is placed in the document body.</p>"], [2, 9, "document.body"]]
7474
import { createPortal } from 'react-dom';
@@ -88,7 +88,7 @@ function MyComponent() {
8888
8989
React will put the DOM nodes for <CodeStep step={1}>the JSX you passed</CodeStep> inside of the <CodeStep step={2}>DOM node you provided</CodeStep>.
9090
91-
Without a portal, the second `<p>` would be placed inside the parent `<div>`, but the portal "teleported" it into the [`document.body`:](https://developer.mozilla.org/en-US/docs/Web/API/Document/body)
91+
Without a Portal, the second `<p>` would be placed inside the parent `<div>`, but the Portal "teleported" it into the [`document.body`:](https://developer.mozilla.org/en-US/docs/Web/API/Document/body)
9292
9393
<Sandpack>
9494
@@ -125,15 +125,15 @@ Notice how the second paragraph visually appears outside the parent `<div>` with
125125
</body>
126126
```
127127
128-
A portal only changes the physical placement of the DOM node. In every other way, the JSX you render into a portal acts as a child node of the React component that renders it. For example, the child can access the context provided by the parent tree, and events still bubble up from children to parents according to the React tree.
128+
A Portal only changes the physical placement of the DOM node. In every other way, the JSX you render into a Portal acts as a child node of the React component that renders it. For example, the child can access the context provided by the parent tree, and events still bubble up from children to parents according to the React tree.
129129
130130
---
131131
132-
### Rendering a modal dialog with a portal {/*rendering-a-modal-dialog-with-a-portal*/}
132+
### Rendering a modal dialog with a Portal {/*rendering-a-modal-dialog-with-a-portal*/}
133133
134-
You can use a portal to create a modal dialog that floats above the rest of the page, even if the component that summons the dialog is inside a container with `overflow: hidden` or other styles that interfere with the dialog.
134+
You can use a Portal to create a modal dialog that floats above the rest of the page, even if the component that summons the dialog is inside a container with `overflow: hidden` or other styles that interfere with the dialog.
135135
136-
In this example, the two containers have styles that disrupt the modal dialog, but the one rendered into a portal is unaffected because, in the DOM, the modal is not contained within the parent JSX elements.
136+
In this example, the two containers have styles that disrupt the modal dialog, but the one rendered into a Portal is unaffected because, in the DOM, the modal is not contained within the parent JSX elements.
137137
138138
<Sandpack>
139139
@@ -164,7 +164,7 @@ export default function NoPortalExample() {
164164
return (
165165
<>
166166
<button onClick={() => setShowModal(true)}>
167-
Show modal without a portal
167+
Show modal without a Portal
168168
</button>
169169
{showModal && (
170170
<ModalContent onClose={() => setShowModal(false)} />
@@ -184,7 +184,7 @@ export default function PortalExample() {
184184
return (
185185
<>
186186
<button onClick={() => setShowModal(true)}>
187-
Show modal using a portal
187+
Show modal using a Portal
188188
</button>
189189
{showModal && createPortal(
190190
<ModalContent onClose={() => setShowModal(false)} />,
@@ -238,7 +238,7 @@ export default function ModalContent({ onClose }) {
238238
239239
<Pitfall>
240240
241-
It's important to make sure that your app is accessible when using portals. For instance, you may need to manage keyboard focus so that the user can move the focus in and out of the portal in a natural way.
241+
It's important to make sure that your app is accessible when using Portals. For instance, you may need to manage keyboard focus so that the user can move the focus in and out of the Portal in a natural way.
242242

243243
Follow the [WAI-ARIA Modal Authoring Practices](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal) when creating modals. If you use a community package, ensure that it is accessible and follows these guidelines.
244244

@@ -248,7 +248,7 @@ Follow the [WAI-ARIA Modal Authoring Practices](https://www.w3.org/WAI/ARIA/apg/
248248

249249
### Rendering React components into non-React server markup {/*rendering-react-components-into-non-react-server-markup*/}
250250

251-
Portals can be useful if your React root is only part of a static or server-rendered page that isn't built with React. For example, if your page is built with a server framework like Rails, you can create areas of interactivity within static areas such as sidebars. Compared with having [multiple separate React roots,](/reference/react-dom/client/createRoot#rendering-a-page-partially-built-with-react) portals let you treat the app as a single React tree with shared state even though its parts render to different parts of the DOM.
251+
Portals can be useful if your React root is only part of a static or server-rendered page that isn't built with React. For example, if your page is built with a server framework like Rails, you can create areas of interactivity within static areas such as sidebars. Compared with having [multiple separate React roots,](/reference/react-dom/client/createRoot#rendering-a-page-partially-built-with-react) Portals let you treat the app as a single React tree with shared state even though its parts render to different parts of the DOM.
252252
253253
<Sandpack>
254254
@@ -344,7 +344,7 @@ p {
344344
345345
### Rendering React components into non-React DOM nodes {/*rendering-react-components-into-non-react-dom-nodes*/}
346346
347-
You can also use a portal to manage the content of a DOM node that's managed outside of React. For example, suppose you're integrating with a non-React map widget and you want to render React content inside a popup. To do this, declare a `popupContainer` state variable to store the DOM node you're going to render into:
347+
You can also use a Portal to manage the content of a DOM node that's managed outside of React. For example, suppose you're integrating with a non-React map widget and you want to render React content inside a popup. To do this, declare a `popupContainer` state variable to store the DOM node you're going to render into:
348348

349349
```js
350350
const [popupContainer, setPopupContainer] = useState(null);

src/content/reference/react/Component.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ You should write the `render` method as a pure function, meaning that it should
573573
574574
#### Returns {/*render-returns*/}
575575
576-
`render` can return any valid React node. This includes React elements such as `<div />`, strings, numbers, [portals](/reference/react-dom/createPortal), empty nodes (`null`, `undefined`, `true`, and `false`), and arrays of React nodes.
576+
`render` can return any valid React node. This includes React elements such as `<div />`, strings, numbers, [Portals](/reference/react-dom/createPortal), empty nodes (`null`, `undefined`, `true`, and `false`), and arrays of React nodes.
577577
578578
#### Caveats {/*render-caveats*/}
579579

src/content/reference/react/cloneElement.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ console.log(clonedElement); // <Row title="Cabbage" isHighlighted={true}>Goodbye
5151

5252
* `props`: The `props` argument must either be an object or `null`. If you pass `null`, the cloned element will retain all of the original `element.props`. Otherwise, for every prop in the `props` object, the returned element will "prefer" the value from `props` over the value from `element.props`. The rest of the props will be filled from the original `element.props`. If you pass `props.key` or `props.ref`, they will replace the original ones.
5353

54-
* **optional** `...children`: Zero or more child nodes. They can be any React nodes, including React elements, strings, numbers, [portals](/reference/react-dom/createPortal), empty nodes (`null`, `undefined`, `true`, and `false`), and arrays of React nodes. If you don't pass any `...children` arguments, the original `element.props.children` will be preserved.
54+
* **optional** `...children`: Zero or more child nodes. They can be any React nodes, including React elements, strings, numbers, [Portals](/reference/react-dom/createPortal), empty nodes (`null`, `undefined`, `true`, and `false`), and arrays of React nodes. If you don't pass any `...children` arguments, the original `element.props.children` will be preserved.
5555

5656
#### Returns {/*returns*/}
5757

src/content/reference/react/createElement.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function Greeting({ name }) {
4242

4343
* `props`: The `props` argument must either be an object or `null`. If you pass `null`, it will be treated the same as an empty object. React will create an element with props matching the `props` you have passed. Note that `ref` and `key` from your `props` object are special and will *not* be available as `element.props.ref` and `element.props.key` on the returned `element`. They will be available as `element.ref` and `element.key`.
4444

45-
* **optional** `...children`: Zero or more child nodes. They can be any React nodes, including React elements, strings, numbers, [portals](/reference/react-dom/createPortal), empty nodes (`null`, `undefined`, `true`, and `false`), and arrays of React nodes.
45+
* **optional** `...children`: Zero or more child nodes. They can be any React nodes, including React elements, strings, numbers, [Portals](/reference/react-dom/createPortal), empty nodes (`null`, `undefined`, `true`, and `false`), and arrays of React nodes.
4646

4747
#### Returns {/*returns*/}
4848

src/content/reference/react/isValidElement.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ console.log(isValidElement({ age: 42 })); // false
4747

4848
#### Caveats {/*caveats*/}
4949

50-
* **Only [JSX tags](/learn/writing-markup-with-jsx) and objects returned by [`createElement`](/reference/react/createElement) are considered to be React elements.** For example, even though a number like `42` is a valid React *node* (and can be returned from a component), it is not a valid React element. Arrays and portals created with [`createPortal`](/reference/react-dom/createPortal) are also *not* considered to be React elements.
50+
* **Only [JSX tags](/learn/writing-markup-with-jsx) and objects returned by [`createElement`](/reference/react/createElement) are considered to be React elements.** For example, even though a number like `42` is a valid React *node* (and can be returned from a component), it is not a valid React element. Arrays and Portals created with [`createPortal`](/reference/react-dom/createPortal) are also *not* considered to be React elements.
5151

5252
---
5353

@@ -109,7 +109,7 @@ function MyComponent() {
109109
A React node can be:
110110

111111
- A React element created like `<div />` or `createElement('div')`
112-
- A portal created with [`createPortal`](/reference/react-dom/createPortal)
112+
- A Portal created with [`createPortal`](/reference/react-dom/createPortal)
113113
- A string
114114
- A number
115115
- `true`, `false`, `null`, or `undefined` (which are not displayed)

0 commit comments

Comments
 (0)