From 6de90dcebbdd72445b2119b28a383f54428ef908 Mon Sep 17 00:00:00 2001 From: petehunt Date: Tue, 18 Feb 2014 23:26:15 -0800 Subject: [PATCH] clone docs --- _data/nav_docs.yml | 2 ++ docs/09.4-test-utils.md | 2 +- docs/09.5-clone-with-props.md | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 docs/09.5-clone-with-props.md diff --git a/_data/nav_docs.yml b/_data/nav_docs.yml index cc1bf201..e52912e1 100644 --- a/_data/nav_docs.yml +++ b/_data/nav_docs.yml @@ -47,6 +47,8 @@ title: Class Name Manipulation - id: test-utils title: Test Utilities + - id: clone-with-props + title: Cloning Components - id: examples title: Examples - title: Reference diff --git a/docs/09.4-test-utils.md b/docs/09.4-test-utils.md index b685787e..8c68fb9d 100644 --- a/docs/09.4-test-utils.md +++ b/docs/09.4-test-utils.md @@ -4,7 +4,7 @@ title: Test Utilities layout: docs permalink: test-utils.html prev: class-name-manipulation.html -next: examples.html +next: clone-with-props.html --- `React.addons.TestUtils` makes it easy to test React components in the testing framework of your choice (we use [Jasmine](http://pivotal.github.io/jasmine/) with [jsdom](https://github.com/tmpvar/jsdom)). diff --git a/docs/09.5-clone-with-props.md b/docs/09.5-clone-with-props.md new file mode 100644 index 00000000..227f9992 --- /dev/null +++ b/docs/09.5-clone-with-props.md @@ -0,0 +1,14 @@ +--- +id: clone-with-props +title: Cloning Components +layout: docs +permalink: clone-with-props.html +prev: test-utils.html +next: examples.html +--- + +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. + +#### `ReactComponent React.addons.cloneWithProps(ReactComponent component, object? extraProps)` + +Do a shallow copy of `component` and merge any props provided by `extraProps`. Props are merged in the same manner as [`transferPropsTo()`](/react/docs/component-api.html#transferpropsto), so props like `className` will be merged intelligently.