[리액트] PropType 과 isRequired propTyles는 props의 타입을 지정할 때 사용한다. 컴포넌트의 proptypes를 지정하는 방법은 defaultProp과 propTypes이다. import PropTypes form 'prop-types'; const MyComponent = ({ name, children }) => { return(...); }; MyComponent.dafaultProps = { name: '홍길동' }; MyComponent.proptTypes = { name: PropTypes.string title: propTypes.number.isRequired //필수설정일 때 씀 }; 많은 propTypes 종류 array: 배열 arrayOf(다른 PropType): 특정 propType 으로 이루어진 배열.. IT/리액트 4년 전
[React] React.js (create-react-app 도구) 간단하게 설치하기 React js (create-react-app) 설치 설치 순서 node js npm yarn create-react-app 도구 visual studio code (에디터) git * 2~4번은 윈도우 cmd를 이용하여 설치 1. node js 설치 - https://nodejs.org/ko/ 에서 - 8.12.0 LTS 버전 설치 - cmd에서 node --version으로 설치 확인 - 개발 폴더 생성 ( 경로: C:\dev\react ) 2. npm 설치 - npm은 node js 패키지 매니저로, 모듈을 설치할 수 있게해준다. - npm은 node js 와 함께 설치된다. node js를 설치했다면 기본으로 설치되며, 따로 설치할 필요 없음 3. yarn 설치 - yarn 도구는 npm 문제점.. IT/리액트 5년 전