App ์ปดํฌ๋ํธ์ img ์ฝ์
โ ํ์ฌ ํด๋ ๊ตฌ์กฐ
โ App.js
import './App.css';
import { BrowserRouter, Route, Routes } from 'react-router-dom';
import Home from './pages/Home';
import New from './pages/New';
import Edit from './pages/Edit';
import Diary from './pages/Diary';
function App() {
return (
<BrowserRouter>
<div className="App">
<h2>App.js</h2>
<img src={process.env.PUBLIC_URL + `/assets/emotion1.png`} />
<Routes>
<Route path="/" element={<Home />} />
<Route path="/new" element={<New />} />
<Route path="/edit" element={<Edit />} />
<Route path="/diary/:id" element={<Diary />} />
</Routes>
</div>
</BrowserRouter>
);
}
export default App;
<img src={process.env.PUBLIC_URL + `/assets/emotion1.png`} />
- process.env.PUBLIC_URL ์ ์ด๋ค ์์น์ ์๋ /public ์ ๊ฐ๋ฆฌํต๋๋ค.
โ ์ฐธ๊ณ
'๐ Front-End > React.js' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Styled-Components (0) | 2022.10.25 |
---|---|
ํ๋ก์ ํธ ๋ฐฐํฌ ์ค๋น ๋ฐ ๋น๋ (0) | 2022.10.25 |
React - Router ์์ฉ (0) | 2022.10.24 |
React - Router ๊ธฐ๋ณธ (0) | 2022.10.24 |
React SPA & CSR (0) | 2022.10.24 |