webpack dev 버전으로 보면 잘 보이는데, build 후 dist file을 보면 화면에 잘 보이지 않는다.
이슈 원인: BrowerRouter가 제대로 build 되지 않았기 때문이다
이슈 해결: HashRouter를 사용한다.
as-is
import * as React from 'react';
import { Switch, BrowserRouter as Router, Route } from 'react-router-dom';
import Home from '../components/Home';
import DynamicPage from '../components/DynamicPage';
const App = () => (
<Router>
<div>
<Switch>
<Route exact path="/" component={Home} />
<Route exact path="/dynamic" component={DynamicPage} />
</Switch>
</div>
</Router>
);
export default App;
to-be
import * as React from 'react';
import { HashRouter, Switch, Route } from 'react-router-dom';
import Home from '../components/Home';
import DynamicPage from '../components/DynamicPage';
const App = () => (
<HashRouter>
<Switch>
<Route exact path="/" component={Home} />
<Route exact path="/dynamic" component={DynamicPage} />
</Switch>
</HashRouter>
);
export default App;
'JavaScript > ETC' 카테고리의 다른 글
| protobuf arrayBuffer 우회하기 (0) | 2019.10.02 |
|---|---|
| [webpack] webpack scripts 명령어에서 분기 처리하는 방법 (0) | 2019.09.09 |
| if 문 true, false (0) | 2019.08.14 |
| webpack 보일러플레이트 만들기 (0) | 2019.08.11 |
| Parcel 기본 셋팅 (0) | 2019.08.09 |