File tree Expand file tree Collapse file tree 1 file changed +33
-3
lines changed Expand file tree Collapse file tree 1 file changed +33
-3
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
- import { Route } from 'react-router-dom' ;
2
+ import { Route , Link , Switch } from 'react-router-dom' ;
3
3
import About from './About' ;
4
4
import Home from './Home' ;
5
+ import Profiles from './Profiles' ;
6
+ import HistorySample from './HistorySample' ;
5
7
6
8
const App = ( ) => {
7
9
return (
8
10
< div >
9
- < Route path = "/" component = { Home } exact = { true } />
10
- < Route path = { [ '/about' , '/info' ] } component = { About } />
11
+ < ul >
12
+ < li >
13
+ < Link to = "/" > 홈</ Link >
14
+ </ li >
15
+ < li >
16
+ < Link to = "/about" > 소개</ Link >
17
+ </ li >
18
+ < li >
19
+ < Link to = "/profiles" > 프로필</ Link >
20
+ </ li >
21
+ < li >
22
+ < Link to = "/history" > History 예제</ Link >
23
+ </ li >
24
+ </ ul >
25
+ < hr />
26
+ < Switch >
27
+ < Route path = "/" component = { Home } exact = { true } />
28
+ < Route path = { [ '/about' , '/info' ] } component = { About } />
29
+ < Route path = "/profiles" component = { Profiles } />
30
+ < Route path = "/history" component = { HistorySample } />
31
+ < Route
32
+ // path를 따로 정의하지 않으면 모든 상황에 렌더링됨
33
+ render = { ( { location } ) => (
34
+ < div >
35
+ < h2 > 이 페이지는 존재하지 않습니다:</ h2 >
36
+ < p > { location . pathname } </ p >
37
+ </ div >
38
+ ) }
39
+ />
40
+ </ Switch >
11
41
</ div >
12
42
) ;
13
43
} ;
You can’t perform that action at this time.
0 commit comments