Inner style prop에 다중 스타일 적용 하기
Example 1)
Style object 에 특정 조건에 따라 스타일을 적용 시킬 경우.
style={ tempVaraiable ? {backGround: 'red'} : {background: 'blue'} }
Example 2)
Style object 에 특정 조건에 따라 다중 스타일을 적용 시킬 경우
style={Object.assign(
{ cursor: currentCellData.onClick ? 'pointer' : 'inherit' },
currentCellData.style && currentCellData.style
)}
- 2개의 스타일 object 를 Object.assign() 을 통해 통합 하고 style prop 으로 전달
'FrontEnd > React' 카테고리의 다른 글
간단한 리덕스의 세 가지 규칙 (0) | 2023.01.30 |
---|---|
JSX 문법에서 왜 여러 Element 들은 하나의 최상위 element에 감싸져 랜더 되어야 하는건가? (0) | 2023.01.16 |
VScode 에서 코드 save 할 때마다 prettier 동작 (0) | 2022.06.29 |
Context API vs Redux (0) | 2022.05.25 |
Class Component vs Functional Component (0) | 2022.05.01 |