React
-
컴포넌트 생성, 사용하기프레임워크/리액트 React 2023. 1. 16. 18:23
컴포넌트 html은 사용이 많아지기 때문에 코드가 더러워지는 단점이 있다. 리액트에서는 이 부분을 해결하기 위해 컴포넌트를 만들어 사용한다. 뿐만 아니라 해당 컴포넌트를 보면, 어떤 기능을 하는지 명확히 알 수 있는 장점도 있다. → 가독성이 좋아지고, 코드의 재활용에 좋다. 1. 컴포넌트(component) 생성 function을 만들고, return() 안에 html 담기 쓰기 또는 1) 주의사항 다른 function 바깥쪽에 작성할 것 function 이름은 영문 대문자로 시작 (ex: Modal) return() 안에는 하나의 태그로 시작해 하나의 태그로 끝나야 함 → 여러개의 태그를 사용하고 싶을 때는 가장 바깥쪽에 로 감싸준다(fragment 문법) → 참고사이트 : https://ko.rea..
-
리액트 설치 및 세팅프레임워크/리액트 React 2023. 1. 14. 17:49
1. 리액트 설치 및 세팅 우선 node.js 최신 버전을(왼쪽 안정화 버전 사용) 다운받아야 함 node.js 버전 확인은 터미널을 연 후 (ctrl + `) npm -v 작업할 폴더를 만든 후 powershell에서 프로젝트를 생성한다. (Create React App을 생성) 리액트 앱을 생성하는 방법은 npm과 npx 방식이 있는데, npm은 프로그램을 설치 npx는 프로그램을 임시로 설치한다.공식 문서에서는 npx 방식을 권장하며, npx는 컴퓨터 공간을 낭비하지 않고, 최신 버전을 유지할 수 있도록 해주는 장점이 있다. npx create-react-app blog //blog대신 임의의 프로젝트명을 입력해도 됨 //npm install -g create-react-app //create-re..