Skip to content

Commit 2919ec5

Browse files
committed
Add router
1 parent 123a4d5 commit 2919ec5

File tree

4 files changed

+48
-2
lines changed

4 files changed

+48
-2
lines changed

src/AboutPage.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import React from 'react'
2+
3+
export default () => {
4+
return <div>About Page</div>
5+
}

src/HomePage.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import React from 'react'
2+
3+
export default () => {
4+
return <div>Home Page</div>
5+
}

src/Navigation.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react'
2+
import { Link } from '@reach/router'
3+
4+
export default () => {
5+
return (
6+
<nav>
7+
<Link>Home</Link>
8+
<Link>About</Link>
9+
</nav>
10+
)
11+
}

src/index.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,34 @@
11
import React from 'react'
22
import ReactDOM from 'react-dom'
3+
import { createGlobalStyle, ThemeProvider } from 'styled-components'
4+
import { Router } from '@reach/router'
5+
import Navigation from './Navigation'
6+
import HomePage from './HomePage'
7+
import AboutPage from './AboutPage'
38

4-
const title = 'Hello React UI Interactions'
9+
const theme = {
10+
fontFamily: 'Helvetica Neue'
11+
}
12+
13+
const GlobalStyle = createGlobalStyle`
14+
body {
15+
font-family: ${props => props.theme.fontFamily};
16+
}
17+
`
518

6-
ReactDOM.render(<div className='application'>{title}</div>, document.getElementById('app'))
19+
ReactDOM.render(
20+
<ThemeProvider theme={theme}>
21+
<React.Fragment>
22+
<Navigation />
23+
<Router>
24+
<HomePage path='/' />
25+
<AboutPage path='about' />
26+
</Router>
27+
<GlobalStyle />
28+
</React.Fragment>
29+
</ThemeProvider>,
30+
document.getElementById('app')
31+
)
732

833
if ('serviceWorker' in navigator) {
934
window.addEventListener('load', () => {

0 commit comments

Comments
 (0)