I have a function component named: Register. I use MUI (Material UI for ReactJS).
Inside it, I call 2 components: Step1 and Step2. Both use data collected through forms.
To simplify I don't post all the code.
<RegisterContextProvider>
{activeStep + 1 === 1 && (<Step1 handleNext={handleNext} />)}
{activeStep + 1 === 2 && (<Step2 handleNext={handleNext} handleBack={handleBack} />)}
</RegisterContextProvider>
When I click the "Next button" inside Step1, I go the next step of the MUI STEPPER component and render: Step2.
Step2 is rendered in the list of children of RegisterContextProvider, and Step1 disappears from the list, and then the data stored in the Step1 form is reinitialized.
Is there a way to wrap the components inside a higher level, like this:
<RegisterContextProvider>
<Register/>
</RegisterContextProvider>
Thank You for advice