Skip to content

Commit 02372e2

Browse files
committed
Added Redux, Router, Thunk & Redux-Router middleware
1 parent 39c0637 commit 02372e2

File tree

13 files changed

+149
-1304
lines changed

13 files changed

+149
-1304
lines changed

README.md

Lines changed: 1 addition & 1244 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
},
88
"dependencies": {
99
"react": "^15.4.2",
10-
"react-dom": "^15.4.2"
10+
"react-dom": "^15.4.2",
11+
"react-redux": "^5.0.1",
12+
"react-router": "^3.0.0",
13+
"react-router-redux": "^4.0.7",
14+
"redux": "^3.6.0",
15+
"redux-thunk": "^2.1.0"
1116
},
1217
"scripts": {
1318
"start": "react-scripts start",

src/App.css

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/App.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
import React, { Component } from 'react';
2-
import logo from './logo.svg';
3-
import './App.css';
2+
import { Link } from 'react-router'
43

54
class App extends Component {
65
render() {
76
return (
8-
<div className="App">
9-
<div className="App-header">
10-
<img src={logo} className="App-logo" alt="logo" />
11-
<h2>Welcome to React</h2>
12-
</div>
13-
<p className="App-intro">
14-
To get started, edit <code>src/App.js</code> and save to reload.
15-
</p>
7+
<div>
8+
<header>
9+
<Link to="/">Home</Link>
10+
<Link to="/about-us">About</Link>
11+
</header>
12+
13+
{this.props.children}
1614
</div>
1715
);
1816
}
1917
}
2018

21-
export default App;
19+
export default App

src/App.test.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/actions/.keep

Whitespace-only changes.

src/containers/about/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import React from 'react'
2+
3+
export default () => (
4+
<div>
5+
<h1>About Us</h1>
6+
<p>We are interesting. I promise!</p>
7+
</div>
8+
)

src/containers/home/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React, { Component } from 'react'
2+
import { push } from 'react-router-redux'
3+
import { connect } from 'react-redux'
4+
5+
class Home extends Component {
6+
goToAboutPage = () => {
7+
this.props.dispatch(push('/about-us'))
8+
}
9+
10+
render() {
11+
return (
12+
<div>
13+
<h1>Home</h1>
14+
<p>Welcome home!</p>
15+
<button onClick={this.goToAboutPage}>Go to about page via redux</button>
16+
</div>
17+
)
18+
}
19+
}
20+
21+
export default connect()(Home)

src/index.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
import React from 'react';
2-
import ReactDOM from 'react-dom';
2+
import { render } from 'react-dom';
33
import App from './App';
44
import './index.css';
5+
import { Provider } from 'react-redux'
6+
import { Router, Route, IndexRoute } from 'react-router'
7+
import store, { history } from './store'
8+
import Home from './containers/home'
9+
import About from './containers/about'
510

6-
ReactDOM.render(
7-
<App />,
8-
document.getElementById('root')
9-
);
11+
render(
12+
<Provider store={store}>
13+
<Router history={history}>
14+
<Route path="/" component={App}>
15+
<IndexRoute component={Home} />
16+
<Route path="/about-us" component={About} />
17+
</Route>
18+
</Router>
19+
</Provider>,
20+
document.querySelector('#root')
21+
)

src/logo.svg

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)