Last active
February 24, 2017 17:54
-
-
Save anomaly44/83c7d7aa0b92997481f50e25800e6f88 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 { Provider } from 'react-redux'; | |
import App from './App'; | |
import './index.css'; | |
import configureStore from './store'; | |
const store = configureStore({ test: "ok" }); | |
store.dispatch({ type: 'TEST' }); | |
const render = (Component) => { | |
return ReactDOM.render( | |
<Provider store={store}> | |
<Component/> | |
</Provider>, | |
document.getElementById('root') | |
); | |
}; | |
render(App); | |
if (module.hot) { | |
module.hot.accept('./App', () => { | |
const NextApp = require('./App').default; | |
ReactDOM.render( | |
<NextApp/>, | |
document.getElementById('root') | |
); | |
}); | |
} |
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 { createStore } from 'redux'; | |
const testReducer = (state = [], action) => { | |
switch (action.type) { | |
case 'TEST': | |
return { | |
...state, | |
cnt: 0 | |
}; | |
case 'ADD': | |
return { | |
...state, | |
cnt: state.cnt + 1 | |
}; | |
default: | |
return state; | |
} | |
}; | |
export default function configureStore(initialState = {}) { | |
const store = createStore( | |
testReducer, | |
initialState, | |
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__() | |
); | |
return store; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment