-
Notifications
You must be signed in to change notification settings - Fork 142
/
links.patch
34 lines (30 loc) · 978 Bytes
/
links.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
diff --git a/src/App.js b/src/App.js
index 3f28b74..295485b 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,14 +1,26 @@
import React from 'react'
import { connect } from 'react-redux'
+import Link from 'redux-first-router-link'
// Contains 'Home', 'User' and 'NotFound'
import * as components from './components'
-const App = ({ page }) => {
+const App = ({ page, changeUser }) => {
const Component = components[page]
- return <Component />
+ return (
+ <div>
+ <Link to="/user/123">User 123</Link>
+ <Link to={{ type: 'USER', payload: { id: 456 } }}>User 456</Link>
+ <button onClick={() => changeUser(789)}>User 789</button>
+ <Component />
+ </div>
+ )
}
const mapStateToProps = ({ page }) => ({ page })
-export default connect(mapStateToProps)(App)
+const mapDispatchToProps = dispatch => ({
+ changeUser: id => dispatch({ type: 'USER', payload: { id } })
+})
+
+export default connect(mapStateToProps, mapDispatchToProps)(App)