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.
 
 
 
 

1.1 KiB

id title permalink prev next
clone-with-props-ko-KR ReactElement 클론하기 clone-with-props-ko-KR.html test-utils-ko-KR.html create-fragment-ko-KR.html

드문 경우긴 하지만 엘리먼트에서 소유하지 않은 엘리먼트의 props를 변경하고 싶을 때가 있습니다. (this.props.children로 전달된 엘리먼트의 className 변경 같은 경우) 아니면 전달된 엘리먼트의 복사본을 여럿 만들고 싶을 수도 있습니다. 이는 cloneWithProps()로 할 수 있습니다.

ReactElement React.addons.cloneWithProps(ReactElement element, object? extraProps)

element를 얕은 복사하고 extraProps로 넘긴 props를 머지합니다. classNamestyle props는 지능적으로 머지됩니다.

주의:

cloneWithPropskey를 클론된 엘리먼트에 전송하지 않습니다. 키를 보존하고 싶으시면, extraProps 객체에 넣으세요.

var clonedElement = cloneWithProps(originalElement, { key : originalElement.key });

비슷하게 ref도 유지되지 않습니다.