Skip to content

Commit 8ed23b1

Browse files
mattrunyongaearon
andauthored
Add key param to createPortal reference (#5928)
* Add key param to createPortal reference * Update createPortal.md * Update createPortal.md * Update createPortal.md --------- Co-authored-by: dan <[email protected]>
1 parent ef55fb2 commit 8ed23b1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ title: createPortal
1010
```js
1111
<div>
1212
<SomeComponent />
13-
{createPortal(children, domNode)}
13+
{createPortal(children, domNode, key?)}
1414
</div>
1515
```
1616
@@ -22,7 +22,7 @@ title: createPortal
2222
2323
## Reference {/*reference*/}
2424
25-
### `createPortal(children, domNode)` {/*createportal*/}
25+
### `createPortal(children, domNode, key?)` {/*createportal*/}
2626
2727
To create a portal, call `createPortal`, passing some JSX, and the DOM node where it should be rendered:
2828
@@ -50,6 +50,8 @@ A portal only changes the physical placement of the DOM node. In every other way
5050
5151
* `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)
54+
5355
#### Returns {/*returns*/}
5456
5557
`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`.

0 commit comments

Comments
 (0)