Skip to content

Commit

Permalink
Add key param to createPortal reference (#5928)
Browse files Browse the repository at this point in the history
* Add key param to createPortal reference

* Update createPortal.md

* Update createPortal.md

* Update createPortal.md

---------

Co-authored-by: dan <[email protected]>
  • Loading branch information
mattrunyon and gaearon authored Apr 29, 2023
1 parent ef55fb2 commit 8ed23b1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/content/reference/react-dom/createPortal.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ title: createPortal
```js
<div>
<SomeComponent />
{createPortal(children, domNode)}
{createPortal(children, domNode, key?)}
</div>
```
Expand All @@ -22,7 +22,7 @@ title: createPortal
## Reference {/*reference*/}
### `createPortal(children, domNode)` {/*createportal*/}
### `createPortal(children, domNode, key?)` {/*createportal*/}
To create a portal, call `createPortal`, passing some JSX, and the DOM node where it should be rendered:
Expand Down Expand Up @@ -50,6 +50,8 @@ A portal only changes the physical placement of the DOM node. In every other way
* `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.
* **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)
#### Returns {/*returns*/}
`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`.
Expand Down

0 comments on commit 8ed23b1

Please sign in to comment.