Skip to content

Commit 5aafb21

Browse files
committed
part 5
1 parent 55de134 commit 5aafb21

File tree

5 files changed

+59
-21
lines changed

5 files changed

+59
-21
lines changed

package-lock.json

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
"dependencies": {
66
"react": "^15.6.1",
77
"react-dom": "^15.6.1",
8-
"react-scripts": "1.0.10"
8+
"react-scripts": "1.0.10",
9+
"redux": "^3.7.2"
910
},
1011
"scripts": {
1112
"start": "react-scripts start",
1213
"build": "react-scripts build",
1314
"test": "react-scripts test --env=jsdom",
1415
"eject": "react-scripts eject"
1516
}
16-
}
17+
}

src/index.js

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,12 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
33
import App from './components/App';
4+
import store from './store';
45
import './index.css';
56
import registerServiceWorker from './registerServiceWorker';
67

7-
const stories = [
8-
{
9-
title: 'React',
10-
url: 'https://facebook.github.io/react/',
11-
author: 'Jordan Walke',
12-
num_comments: 3,
13-
points: 4,
14-
objectID: 0,
15-
}, {
16-
title: 'Redux',
17-
url: 'https://github.com/reactjs/redux',
18-
author: 'Dan Abramov, Andrew Clark',
19-
num_comments: 2,
20-
points: 5,
21-
objectID: 1,
22-
},
23-
];
24-
258
ReactDOM.render(
26-
<App stories={stories} onArchive={() => {}} />,
9+
<App stories={store.getState()} />,
2710
document.getElementById('root')
2811
);
2912
registerServiceWorker();

src/reducers/story.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const INITIAL_STATE = [
2+
{
3+
title: 'React',
4+
url: 'https://facebook.github.io/react/',
5+
author: 'Jordan Walke',
6+
num_comments: 3,
7+
points: 4,
8+
objectID: 0,
9+
}, {
10+
title: 'Redux',
11+
url: 'https://github.com/reactjs/redux',
12+
author: 'Dan Abramov, Andrew Clark',
13+
num_comments: 2,
14+
points: 5,
15+
objectID: 1,
16+
},
17+
];
18+
19+
function storyReducer(state = INITIAL_STATE, action) {
20+
switch(action.type) {
21+
default : return state;
22+
}
23+
}
24+
25+
export default storyReducer;

src/store/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { createStore } from 'redux';
2+
import storyReducer from '../reducers/story';
3+
4+
const store = createStore(
5+
storyReducer
6+
);
7+
8+
export default store;

0 commit comments

Comments
 (0)