From fa05a157e4d90a4513d366c601418677b59892c7 Mon Sep 17 00:00:00 2001 From: Jim Date: Wed, 22 Jul 2015 09:00:16 -0700 Subject: [PATCH] Merge pull request #4459 from tako-black/translate_clone-with-props_to_japanese Translate 10.5-clone-with-props.md to Japanese (cherry picked from commit 3dcc4b8b906679dd80b4e4f0b354e94f320f05da) --- docs/docs/10.5-clone-with-props.ja-JP.md | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 docs/docs/10.5-clone-with-props.ja-JP.md diff --git a/docs/docs/10.5-clone-with-props.ja-JP.md b/docs/docs/10.5-clone-with-props.ja-JP.md new file mode 100644 index 0000000000..655f90f882 --- /dev/null +++ b/docs/docs/10.5-clone-with-props.ja-JP.md @@ -0,0 +1,34 @@ +--- +id: clone-with-props +title: ReactElementsをクローンすること +permalink: clone-with-props-ja-JP.html +prev: test-utils-ja-JP.html +next: create-fragment-ja-JP.html +--- + +> 注意: +> `cloneWithProps` は使用不可になりました。[React.cloneElement](top-level-api-ja-JP.html#react.cloneelement)を代わりに使用してください。 + +元のReact要素とは異なるプロパティを持った要素のコピーを作成したいと考える稀なケースがあるかと思います。1つの例としては、以下のように、 `this.props.children` に渡すように要素をクローンし、異なるプロパティを持つようそれらをレンダリングするものです。 + +```js +var _makeBlue = function(element) { + return React.addons.cloneWithProps(element, {style: {color: 'blue'}}); +}; + +var Blue = React.createClass({ + render: function() { + var blueChildren = React.Children.map(this.props.children, _makeBlue); + return
{blueChildren}
; + } +}); + +React.render( + +

This text is blue.

+
, + document.getElementById('container') +); +``` + +`cloneWithProps` は `key` や `ref` をクローンされた要素に渡すことはありません。 `className` や `style` は自動的にマージされます。 \ No newline at end of file