Skip to content

Commit

Permalink
react-router를 이용하여 간단한 어플리케이션 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
hoilzz committed Feb 10, 2019
1 parent d00c8bc commit f550935
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 4 deletions.
83 changes: 82 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"react": "^16.8.1",
"react-dom": "^16.8.1",
"react-hot-loader": "^4.6.5",
"react-prop-types": "^0.4.0"
"react-prop-types": "^0.4.0",
"react-router-dom": "^4.3.1"
}
}
19 changes: 17 additions & 2 deletions src/components/App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
import React from "react";
import { hot } from 'react-hot-loader/root'
import { hot } from "react-hot-loader/root";
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";

const App = () => <div>hoilzzzz</div>;
import Home from "./Home";
import AsyncPage from "./AsyncPage";
import NoPage from "./NoPage";

const App = () => (
<Router>
<div>
<Switch>
<Route exact path="/" component={Home} />
<Route exact path="/async" component={AsyncPage} />
<Route component={NoPage} />
</Switch>
</div>
</Router>
);

export default hot(App);
13 changes: 13 additions & 0 deletions src/components/AsyncPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from "react";
import { Link } from "react-router-dom";

const AsyncPage = () => (
<div>
<div>
<Link to="/">home으로 이동하기</Link>
</div>
AsyncPage 입니당.
</div>
);

export default AsyncPage;
13 changes: 13 additions & 0 deletions src/components/Home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from "react";
import { Link } from 'react-router-dom';

const Home = () => <div>
<div>
<Link to="/async">async로 이동</Link>


</div>
hoilzz 의 home 입니다
</div>;

export default Home;
5 changes: 5 additions & 0 deletions src/components/NoPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from "react";

const NoPage = () => <div>404입니다</div>;

export default NoPage;

0 comments on commit f550935

Please sign in to comment.