parent
d3645c30a0
commit
b623f941bf
@ -1,8 +1,12 @@
|
|||||||
import ReactDOM from 'react-dom';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import ReactDOM from 'react-dom';
|
||||||
import Comments from './components/comments.jsx';
|
import Comments from './components/comments.jsx';
|
||||||
|
import { Provider } from 'react-redux';
|
||||||
|
import store from './store.js';
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<Comments></Comments>,
|
<Provider store={store}>
|
||||||
|
<Comments></Comments>
|
||||||
|
</Provider>,
|
||||||
document.querySelector('main')
|
document.querySelector('main')
|
||||||
);
|
);
|
||||||
|
|||||||
@ -0,0 +1,14 @@
|
|||||||
|
import { createStore } from 'redux'
|
||||||
|
|
||||||
|
let comments = function(state = [], action){
|
||||||
|
switch(action.type){
|
||||||
|
case 'ADD':
|
||||||
|
return [...state, action.comment];
|
||||||
|
default:
|
||||||
|
return state
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let store = createStore(comments);
|
||||||
|
|
||||||
|
export default store;
|
||||||
Loading…
Reference in new issue