network-resurrector-frontend/src/state/reducer.js

23 lines
473 B
JavaScript

export function reducer(state, action) {
switch (action.type) {
case "onNetworkChange": {
const { prop, value } = action.payload;
return {
...state,
network: {
...state.network,
[prop]: value
}
};
}
default: {
return state;
}
}
}
export const dispatchActions = dispatch => ({
onNetworkChange: (prop, value) =>
dispatch({ type: "onNetworkChange", payload: { prop, value } })
});