React Native (feat. Redux) React Native (feat. Redux)

Exercise: Adding an Exercise

Check out a free preview of the full React Native (feat. Redux) course:
The "Exercise: Adding an Exercise" Lesson is part of the full, React Native (feat. Redux) course featured in this preview video. Here's what you'd learn in this lesson:

In this exercise, you will create a new action and implement the add-exercise functionality. When an exercise in the modal is tapped, it will be added to the currentWorkout array.

Get Unlimited Access Now

Transcript from the "Exercise: Adding an Exercise" Lesson

>> [MUSIC]

>> Scott: So based on what we have here, so on this ExerciseList, when it renders it's gonna have a list of exercises. I wanna be able to tap on that exercise and have it add the exercise that I tapped on to the current workout array. So you need to make another action that when clicked is gonna add the current exercise.

[00:00:24] So if you go look in the ExerciseList here, the current exercise would be this exercise right here. So you'd probably do like a button or highlight opacity or something like that to be able to on-press. So, on-press, we want to fire off an action that we need to create.

[00:00:41] And we can call that addExercise. And we want that action to add exercise to the current workout. So on our current workout reducer, it's actually already here. ADD_EXERCISE_COMPLETE. And that's because it's gonna be async, but we're gonna do async after we do this. So if you could just make an action, whatever you wanna call it.

[00:01:00] Mine is called ADD_EXERCISE_COMPLETE. And it's just gonna add it to the addExcercise array, just push it in there. And that's it. And that's all you gotta do.