1. 下載 node.js
2. 開啟終端機前往指定的資料夾或是位置,輸入下方的指令來建立 React 專案。
npx create-app my-app
cd mp-app
npm start
Windows的部分,也是打開終端機輸入相同的指令: npx create-react-app <folder_name>
3.刪除不必要的檔案(這部分就會看你的需求決定)
- ./src 只需要留下 index.js 和 index.css。
- index.js 修改成:
import React from 'react'; import ReactDOM from 'react-dom/client'; import './index.css'; import Home from "./pages/Home" const root = ReactDOM.createRoot(document.getElementById('root')); root.render( <Home /> );