From the course: React: Design Patterns (2021)

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Controlled onboarding flows

Controlled onboarding flows

- [Instructor] Okay, so we've seen how to create an uncontrolled onboarding flow component. Let's take a look at how we can convert this component into a controlled component. So the first thing we're going to do is create a new file for our controlled onboarding flow component, which we'll, of course, call ControlledOnboardingFlow.js. And inside here, what we're going to do is copy and paste all of the code from our uncontrolled onboarding flow. And we'll start off by changing the name here to Controlled Onboarding Flow. And just like we saw with our modal component, the main change we're going to make here is, instead of keeping track of the onboarding data and current index inside the onboarding flow itself, we're going to pass those things in as props from the parent component. So in addition to having children and on finish as props, it's also going to take a current index prop and an on next prop. All right, so…

Contents