[React] 컴포넌트에서 조건부로 props 전달하는 방법

SangBooom·2022년 9월 7일
0
<Component {...(editable && { editable: editableOpts } )} />
 
<Component {...(this.props.editable && { editable: this.props.editableOpts })} />

<Component {...(canClick && { onClick: this.handler })} />

단축 평가를 통해 좌측 피연산자가 true 일때 우측 피연산자를 평가시킨다.

profile
끊임없이 떨어지는 물방울이 바위를 뚫는다

0개의 댓글