Created
November 18, 2017 22:26
-
-
Save inoh/c73cc9df784cc5bfb7f50352d3e4a835 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import { createStore, combineReducers } from 'redux' | |
import { Provider } from 'react-redux' | |
import App from './containers/App'; | |
// hellosの初期データ | |
const initalHellos = [{ | |
value: 'よろしく!', | |
note: 'Hello World!!', | |
}]; | |
// hellosのreducer定義 | |
const hellos = (state = initalHellos, action) => { | |
switch (action.type) { | |
case 'ADD_HELLO': | |
return [ | |
...state, | |
action.payload, | |
] | |
default: | |
return state | |
} | |
}; | |
// reducerの作成 | |
const reducer = combineReducers({ | |
hellos, | |
}); | |
// Storeの作成 | |
const store = createStore(reducer); | |
// ProvierにStoreを登録 | |
ReactDOM.render( | |
<Provider store={store}> | |
<App /> | |
</Provider>, | |
document.getElementById('root') | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment