You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
1.1 KiB
24 lines
1.1 KiB
10 years ago
|
---
|
||
|
id: clone-with-props-ko-KR
|
||
|
title: ReactElement 클론하기
|
||
|
permalink: clone-with-props-ko-KR.html
|
||
|
prev: test-utils-ko-KR.html
|
||
|
next: update-ko-KR.html
|
||
|
---
|
||
|
|
||
|
드문 경우긴 하지만 엘리먼트에서 소유하지 않은 엘리먼트의 props를 변경하고 싶을 때가 있습니다. (`this.props.children`로 전달된 엘리먼트의 `className` 변경 같은 경우) 아니면 전달된 엘리먼트의 복사본을 여럿 만들고 싶을 수도 있습니다. 이는 `cloneWithProps()`로 할 수 있습니다.
|
||
|
|
||
|
#### `ReactElement React.addons.cloneWithProps(ReactElement element, object? extraProps)`
|
||
|
|
||
|
`element`를 얕은 복사하고 `extraProps`로 넘긴 props를 머지합니다. `className`과 `style` props는 지능적으로 머지됩니다.
|
||
|
|
||
|
> 주의:
|
||
|
>
|
||
|
> `cloneWithProps`는 `key`를 클론된 엘리먼트에 전송하지 않습니다. 키를 보존하고 싶으시면, `extraProps` 객체에 넣으세요.
|
||
|
>
|
||
|
> ```js
|
||
|
> var clonedElement = cloneWithProps(originalElement, { key : originalElement.key });
|
||
|
> ```
|
||
|
>
|
||
|
> 비슷하게 `ref`도 유지되지 않습니다.
|