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