Fix a doc. cloneWithProps clones a ReactElement.
Toru Kobayashi committed
Feb 15, 2015 at 23:50 UTC
60e96edce2ec46743eb926df5bc07ee97ab1271a
2 files changed
+7
-7
docs/docs/10.5-clone-with-props.md
+6
-6
@@ -1,23 +1,23 @@
1
---
2
id: clone-with-props
3
-title: Cloning Components
3
+title: Cloning ReactElement
4
permalink: clone-with-props.html
5
prev: test-utils.html
6
next: update.html
7
---
8
9
-In rare situations a component may want to change the props of a component that it doesn't own (like changing the `className` of a component passed as `this.props.children`). Other times it may want to make multiple copies of a component passed to it. `cloneWithProps()` makes this possible.
9
+In rare situations a element may want to change the props of a element that it doesn't own (like changing the `className` of a element passed as `this.props.children`). Other times it may want to make multiple copies of a element passed to it. `cloneWithProps()` makes this possible.
10
11
-#### `ReactComponent React.addons.cloneWithProps(ReactComponent component, object? extraProps)`
11
+#### `ReactElement React.addons.cloneWithProps(ReactElement element, object? extraProps)`
12
13
-Do a shallow copy of `component` and merge any props provided by `extraProps`. The `className` and `style` props will be merged intelligently.
13
+Do a shallow copy of `element` and merge any props provided by `extraProps`. The `className` and `style` props will be merged intelligently.
14
15
> Note:
16
>
17
-> `cloneWithProps` does not transfer `key` to the cloned component. If you wish to preserve the key, add it to the `extraProps` object:
17
+> `cloneWithProps` does not transfer `key` to the cloned element. If you wish to preserve the key, add it to the `extraProps` object:
18
>
19
> ```js
20
-> var clonedComponent = cloneWithProps(originalComponent, { key : originalComponent.key });
20
+> var clonedElement = cloneWithProps(originalElement, { key : originalElement.key });
21
> ```
22
>
23
> `ref` is similarly not preserved.
src/utils/cloneWithProps.js
+1
-1
@@ -24,7 +24,7 @@ var CHILDREN_PROP = keyOf({children: null});
24
* Sometimes you want to change the props of a child passed to you. Usually
25
* this is to add a CSS class.
26
*
27
- * @param {ReactElement} child child component you'd like to clone
27
+ * @param {ReactElement} child child element you'd like to clone
28
* @param {object} props props you'd like to modify. className and style will be
29
* merged automatically.
30
* @return {ReactElement} a clone of child with props merged in.