Duration
3 min
Access
Free
Transcript
Available

Our Wizard component provide a good amount of flexibility but in the previous step we had to forcibly add a prop to the main component to know the total number of steps or pages that the user want to render. The prop steps.

We can get rid of that and "automate" the retrieval and calculation of this data by using the useEffect hook.

useEffect is the hook used by React to execute side effects that is any action required to synchronize an internal and external state. In this case we want to use the useEffect hook to emit the effect of calculate the steps when the component is rendered.