SOURCE

reducer=(state = [],action)=>{
  if(action.type === 'split_string'){
    return action.payload.split('');
  }else if(action.type === 'add_character'){
    return [...state, action.payload ];
  }
  return state;
}

function render(){
  document.querySelector('body').innerHTML = store.getState();
}

var store = Redux.createStore(reducer);
store.subscribe(render);
// render();
action = {
  type: 'split_string',
  payload: 'abcd'
}

store.dispatch(action);

action2 = {
  type: 'add_character',
  payload: 'e'
}

store.dispatch(action2);
console 命令行工具 X clear

                    
>
console