์ํฉ
react-route-dom์ ์ค์นํ๊ณ App.js์ ์ฝ๋๋ฅผ ์์ฑํ๋ ์๋ฌ๊ฐ ๋ฐ์ํ๋ค.
<Route path="/today" component={Today}/>
<Route path="/new" component={New}/>
<Route path="/hot" component={Hot}/>
<Route path="/product" component={Product}/>
์๋ฌ ์ฝ๋
Error: Invariant failed: You should not use <Route> outside a <Router>
ํด๊ฒฐ ๋ฐฉ๋ฒ
1.github issue / Error: Invariant failed: You should not use <Route>
outside a <Router>
2.Error: Invariant failed: You should not use <Route>
outside a <Router>
index.js์ ์์นํ <App />
์ <BrowserRouter>
๋ก ๋ฌถ์ด์ฃผ๋ฉด ๋๋ค!
ReactDOM.render(
<React.StrictMode>
<BrowserRouter>
<App />
</BrowserRouter>
</React.StrictMode>,
document.getElementById('root')
);
BrowserRouter๊ฐ ๋ญ์ง ๊ณต๋ถํ๊ณ ์ ๋ฆฌํด๋ด์ผ๊ฒ ๋ค.