console
const counter = (state = 0, action) => {
switch (action.type) {
case 'INCREMENT':
return state + 1 ;
case 'DECREMENT':
return state - 1 ;
default:
return state;
}
}
const { createStore } = Redux;
const store = createStore(counter);
const render = () => {
document.body.innerText = store.getState();
}
store.subscribe(render);
render();
document.addEventListener(‘click’, () => {
store.dispatch({ type : 'INCREMENT' })
})
<title> test </title>
<script src="http://cdn.bootcss.com/redux/3.6.0/redux.js"></script>