react:reducer-creator

function createReducer(initialState, handlers) {
return function reducer(state = initialState, action) {
if (handlers.hasOwnProperty(action.type)) {
return handlers[action.type](state, action)
} else {
return state
}
}
} const todosreducer = createReducer([], {
'ADD_TODO': addTodo,
'TOGGLE_TODO': toggleTodo,
'EDIT_TODO': editTodo
});
上一篇:查看80端口被占用的方法(IIS、apmserv、system)


下一篇:面试阿里,字节跳动,华为必须知道的Java创建对象的5种方式