
But be sure to take a look at the demo for the full code. Since the child components look almost similar between one another, I’m just gonna show one of them here. We’re keeping things pretty barebones for this example by only using one input per step, but each step could really be as complex as we’d like. Creating the step (child) componentsįirst, we’ll create the form’s child components. Will supply both data and function into child components, and child components will pass user inputs back to the parent using its props. will render a password input and a submit button.component will render an email address input.The step child (get it?) components will receive props from the parent component for value and onChange props. It’s one big happy family over here!We’ll need a function to move the form from one step to another as well, and we’ll get to that a little later. In the diagram above, will send data and functions to the child components via props, and in turn, the child components will trigger a handleChange() function to set values in the state of. Instead of having one form component, we will have one parent component and three child components. Props are used for passing data and function into elements.Component is used for writing methods and the interface.State is used for storing data and user inputs.serves as the container while three child components inside of it act as each step of the form.Īlthough it seems to be more complex than a regular form, a multi-step form still uses the same principles as a React form: Here’s a visual showing that container ( ), the components inside of it (, , ) and the way states and props are passed between them. You can then use any of those icons anywhere in your app without needing to re-import into each component.The easiest way to create a multi-step form is to create a container form element that contains all the steps inside of it as components. faTwitter, faFontAwesome, faHatCowboy, faHatChef, and faPlateUtensils: Adding each of these icons individually allows us to refer to them throughout our app by their icon string names, twitter, font-awesome, hat-cowboy, hat-chef, and plate-utensils.



For example: coffee, check-square, or spinner. fas: which represents all of the icons in (Be careful importing whole styles - it can be a LOT of icons!) So any of the icons in that package may be referenced by icon name as a string anywhere else in our app.In our call to library.add() we’re passing: add (fas, faTwitter, faFontAwesome, faHatCowboy, faHatChef, faPlateUtensils )
