Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save TheeBryanWhite/c8e7900bd09b9e1d2cee6a44cb6816dd to your computer and use it in GitHub Desktop.
Save TheeBryanWhite/c8e7900bd09b9e1d2cee6a44cb6816dd to your computer and use it in GitHub Desktop.
// ROOT REDUCER
function rootReducer(state = initialState, action) {
switch (action.type) {
case STORE_EXERCISE:
return Object.assign({}, state, {
workoutToSave: state.workoutToSave.map((workout, index) => {
if (index === action.payload.index) {
return {exercise: action.payload.exercise};
} else {
return {exercise: { id: action.payload.exercise.id}};
}
})
});
break;
default:
return state;
}
}
// THE ACTION
// Nothing funky
export const storeExerciseData = (exercise) => {
return {
type: STORE_EXERCISE,
payload: exercise
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment