File tree Expand file tree Collapse file tree 5 files changed +44
-20
lines changed Expand file tree Collapse file tree 5 files changed +44
-20
lines changed Original file line number Diff line number Diff line change 55 "dependencies" : {
66 "react" : " ^15.6.1" ,
77 "react-dom" : " ^15.6.1" ,
8+ "react-redux" : " ^5.0.5" ,
89 "react-scripts" : " 1.0.10" ,
910 "redux" : " ^3.7.2" ,
1011 "redux-logger" : " ^3.0.6"
Original file line number Diff line number Diff line change @@ -3,12 +3,9 @@ import './App.css';
33
44import Stories from './Stories' ;
55
6- const App = ( { stories , onArchive } ) =>
6+ const App = ( ) =>
77 < div className = "app" >
8- < Stories
9- stories = { stories }
10- onArchive = { onArchive }
11- />
8+ < Stories />
129 </ div >
1310
1411export default App ;
Original file line number Diff line number Diff line change 11import React from 'react' ;
2+ import { connect } from 'react-redux' ;
3+ import { doArchiveStory } from '../actions/archive' ;
4+ import { getReadableStories } from '../selectors/story' ;
25import './Stories.css' ;
36
47import Story from './Story' ;
@@ -51,4 +54,15 @@ const StoriesHeader = ({ columns }) =>
5154 ) }
5255 </ div >
5356
54- export default Stories ;
57+ const mapStateToProps = state => ( {
58+ stories : getReadableStories ( state ) ,
59+ } ) ;
60+
61+ const mapDispatchToProps = dispatch => ( {
62+ onArchive : id => dispatch ( doArchiveStory ( id ) ) ,
63+ } ) ;
64+
65+ export default connect (
66+ mapStateToProps ,
67+ mapDispatchToProps
68+ ) ( Stories ) ;
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import ReactDOM from 'react-dom' ;
3+ import { Provider } from 'react-redux' ;
34import App from './components/App' ;
45import store from './store' ;
5- import { getReadableStories } from './selectors/story' ;
6- import { doArchiveStory } from './actions/archive' ;
76import './index.css' ;
87import registerServiceWorker from './registerServiceWorker' ;
98
10- function render ( ) {
11- ReactDOM . render (
12- < App
13- stories = { getReadableStories ( store . getState ( ) ) }
14- onArchive = { id => store . dispatch ( doArchiveStory ( id ) ) }
15- /> ,
16- document . getElementById ( 'root' )
17- ) ;
18- }
19-
20- store . subscribe ( render ) ;
21- render ( ) ;
9+ ReactDOM . render (
10+ < Provider store = { store } >
11+ < App />
12+ </ Provider > ,
13+ document . getElementById ( 'root' )
14+ ) ;
2215
2316registerServiceWorker ( ) ;
You can’t perform that action at this time.
0 commit comments