Skip to content

Instantly share code, notes, and snippets.

@inoh
Created November 18, 2017 22:26
Show Gist options
  • Save inoh/c73cc9df784cc5bfb7f50352d3e4a835 to your computer and use it in GitHub Desktop.
Save inoh/c73cc9df784cc5bfb7f50352d3e4a835 to your computer and use it in GitHub Desktop.
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