Skip to content

Commit 784430f

Browse files
committed
react-redux-tutorial2
1 parent ec3392c commit 784430f

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

react-redux-tutorial/src/index.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1-
import React from 'react';
2-
import ReactDOM from 'react-dom';
3-
import './index.css';
4-
import App from './App';
5-
import * as serviceWorker from './serviceWorker';
1+
// import React from 'react';
2+
// import ReactDOM from 'react-dom';
3+
// import './index.css';
4+
// import App from './App';
5+
// import * as serviceWorker from './serviceWorker';
66

7-
ReactDOM.render(<App />, document.getElementById('root'));
7+
// ReactDOM.render(<App />, document.getElementById('root'));
88

9-
// If you want your app to work offline and load faster, you can change
10-
// unregister() to register() below. Note this comes with some pitfalls.
11-
// Learn more about service workers: https://bit.ly/CRA-PWA
12-
serviceWorker.unregister();
9+
// // If you want your app to work offline and load faster, you can change
10+
// // unregister() to register() below. Note this comes with some pitfalls.
11+
// // Learn more about service workers: https://bit.ly/CRA-PWA
12+
// serviceWorker.unregister();
13+
14+
// import store from "./js/store/index";
15+
// import { addArticle } from "./js/actions/index";
16+
// window.store = store;
17+
// window.addArticle = addArticle;
18+
import React from "react";
19+
import { render } from "react-dom";
20+
import { Provider } from "react-redux";
21+
import store from "./store/index";
22+
import App from "./components/App.jsx";
23+
// if you're in create-react-app import the files as:
24+
import store from "./js/store/index";
25+
// import App from "./js/components/App.jsx";

react-redux-tutorial/src/reducers/index.js renamed to react-redux-tutorial/src/js/reducers/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ const initialState = {
77
//As a second parameter we’ll provide action.
88
function rootReducer(state = initialState, action) {
99
if(action.type === ADD_ARTICLE) {
10+
return Object.assign({}, state, { // The state is immutable and cannot change in place.
11+
articles : state.articles.concat([action.payload])
12+
})
1013
}
1114
return state;
1215
}

0 commit comments

Comments
 (0)