-
[react] 개발 환경을 구축하자React.js/react 2022. 12. 7. 19:23
🎈 npm 명령어를 사용하기 위해서는 Node.js 설치가 필요하다.
윈도우에서 npm 명령어 사용하기 (npm, node.js 설치)
먼저, npm 명령어를 사용하기 위해서는 Node.js의 설치가 필요합니다. 1. 아래의 링크에서 Node.js를 설치해줍니다. LTS는 안정되어있는 버전이고, Current는 가장 최신의 버전이라고 생각하시면 됩니다.
nomoneynohappy.tistory.com
👉🏻 01. 리액트 프로젝트 생성
- npm init react-app .(현재 폴더)
-- Typescript
- npx create-react-app . --template typescript
👉🏻 02. react router dom 설치
npm install react-router-dom
index.js
import {BrowserRouter} from 'react-router-dom'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render( <React.StrictMode> <BrowserRouter><App /></BrowserRouter> </React.StrictMode> );구성
<Link to/> <Routes> <Route path, element /> </Routes>https://ddiddibbung.tistory.com/6
👉🏻 03. Axios 설치
https://www.npmjs.com/package/axios
👉🏻 04. JSON Server 설치
https://www.npmjs.com/package/json-server
- package.json : 명령어와 port번호를 간편하게 바꾸자
"scripts": { "db": "json-server --watch db.json --port 3001", },- db.json 파일을 생성하자
{ "posts":[] }- npm run db : json-server 실행하자
👉🏻 05. 개발모드 실행
npm (run) start
👉🏻 06. 개발모드 종료
ctrl + c
👉🏻 07. styled-components 설치
> npm i styled-components > npm i @types/styled-components // typescript 사용시'React.js > react' 카테고리의 다른 글
[react] react에서 <select> 사용하기 예시소스 (0) 2022.12.27 [axios] post / get / delete / put 으로 데이터를 처리하자 (0) 2022.12.07 [react-router-dom] <Link> : 링크 걸기 (0) 2022.12.07 [react] array를 보여줄 때는 map() 함수를 사용하자 (0) 2022.12.07 JSX 문법 · component · props (0) 2022.12.07