RESET across multiple reducersimport todoReducer from './todo.store.js';
import itemReducer from './item.store.js';
let reducers = combineReducers({
todo: todoReducer,
item: itemReducer,
});
import * as actions from "../../store/todo.store.js";
import * as itemActions from "../../store/item.store.js";
const mapStateToProps = state => ({
todo: state.todo,
item: state.item,
});
const mapDispatchToProps = (dispatch, getState) => ({
deleteItem: id => dispatch(actions.deleteItem(id)),
hideDetails: id => dispatch(itemActions.hideDetails()),
});
RESET//counter.store.js
export default function reducer (state = initialState, action) {
switch (action.type) {
case 'INCREMENT':
return { value: state.value + 1 }
case 'RESET':
return {value:0};
default:
return state;
}
}
//history.store.js
export default function reducer (state = initialState, action) {
switch (action.type) {
case 'CLICK':
return { clicks: state.clicks + 1 }
case 'RESET':
return {clicks:0};
default:
return state;
}
}