.sass | .scss |
중괄호와 세미콜론 사용하지 않음 | 중괄호와 세미콜론 사용함 기존 CSS 문법과 크게 다르지 않음 |
*node sass version 5.0.0 is incompatible with ^4.0.0 오류 뜰 때*
$ npm uninstall node-sass
$ npm install node-sass@4.14.1
$ yarn start
후 정상작동함node sass version 5.0.0 is incompatible with ^4.0.0.
[출처] [React] Error: node sass version 5.0.0 is incompatible with ^4.0.0. 뜰 때|작성자 밍디
: CSS 클래스를 조건부로 설정할 때 매우 유용한 라이브러리
yarn add classnames를 통해 설치
import classNames from 'classnames';
classNames('one','two'); // = 'one two'
classNames('one', {two: true}); // = 'one two'
classNames('one', {two: false}); // = 'one'
classNames('one',['two', 'three']); // = 'one two three'
const myClass = 'hello';
classNames('one', myClass, {myCondition: true}); // = 'one hello myCondition'
props
const MyComponent = ({highlighted, theme}) => (
<div className={classNames('MyComponent', {highlighted}, theme)}>Hello</div>
);
[React] Hooks: useState, useEffect, useReducer (0) | 2022.05.31 |
---|---|
[React] map과 filter를 통한 배열 관리 (0) | 2022.04.28 |
[React] 컴포넌트비교, 모듈 내보내기 및 가져오기, props, state (0) | 2022.04.15 |
리액트를 다루는 기술 11장 (0) | 2021.01.21 |
리액트를 다루는 기술 10장 (0) | 2021.01.21 |