Skip to content

Commit 819f945

Browse files
authored
Update cloneElement.md to match types in @types/react
1 parent a5aad0d commit 819f945

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/content/reference/react/cloneElement.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ console.log(clonedElement); // <Row title="Cabbage" isHighlighted={true}>Goodbye
4949

5050
* `element`: The `element` argument must be a valid React element. For example, it could be a JSX node like `<Something />`, the result of calling [`createElement`](/reference/react/createElement), or the result of another `cloneElement` call.
5151

52-
* `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.
52+
* `props`: The `props` argument must either be an object or `undefined`. If you pass `undefined`, 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

5454
* **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

@@ -68,7 +68,7 @@ Usually, you'll return the element from your component or make it a child of ano
6868

6969
* Cloning an element **does not modify the original element.**
7070

71-
* You should only **pass children as multiple arguments to `cloneElement` if they are all statically known,** like `cloneElement(element, null, child1, child2, child3)`. If your children are dynamic, pass the entire array as the third argument: `cloneElement(element, null, listItems)`. This ensures that React will [warn you about missing `key`s](/learn/rendering-lists#keeping-list-items-in-order-with-key) for any dynamic lists. For static lists this is not necessary because they never reorder.
71+
* You should only **pass children as multiple arguments to `cloneElement` if they are all statically known,** like `cloneElement(element, undefined, child1, child2, child3)`. If your children are dynamic, pass the entire array as the third argument: `cloneElement(element, undefined, listItems)`. This ensures that React will [warn you about missing `key`s](/learn/rendering-lists#keeping-list-items-in-order-with-key) for any dynamic lists. For static lists this is not necessary because they never reorder.
7272

7373
* `cloneElement` makes it harder to trace the data flow, so **try the [alternatives](#alternatives) instead.**
7474

0 commit comments

Comments
 (0)