исходный код: < /p>
Код: Выделить всё
const state = {count: 0}
const reducers = {
add: (state) => ({count: state.count + 1}),
sub: (state) => ({count: state.count - 1}),
}
< /code>
Моя глупая версия: < /p>
const myReducersAsAnObject = {
add : function (state) {
return count = state.count + 1
},
sub: function (state){
return count = state.count - 1
}
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... t-reducers