A demonstration of how to use an XState state machine to manage which page the user is on in a wizard form.
Infobip Shift 2021 – Zadar, CroatiaYou're a Wizard Form,Harry.Erik Rasmussen – @erikras
View Slide
Forms?
A Wizard Form isa form that is broken into several steps.Erik Rasmussen – @erikras
When to use a Wizard Form?•Really long forms•Dynamic formsErik Rasmussen – @erikras
Wizard Form Implementation•Array of "pages"•next = ()=>index += 1•previous = ()=>index -= 1•State MachineErik Rasmussen – @erikras
Potion Ocean - Requirements• Four pages:• Contact Info• Ingredients• Delivery Preference• Delivery Address• Validation on "Next"• ..but not on "Previous"!• Don't ask for Delivery Address if user chooses "Pick Up"Erik Rasmussen – @erikras
Erik Rasmussen – @erikras
Wizard Form State MachineErik Rasmussen – @erikras
Erik Rasmussen – @erikrasWizard Form State Machine
Erik Rasmussen – @erikrashttps://react-final-form.orgREACT FINAL FORM
Form Library Handles•Accumulating our form values•Field-level validation•Block submit when there are invalidfields•Markingfields as "touched" when submit isblockedErik Rasmussen – @erikras
Erik Rasmussen – @erikrasLet's Code!
http://github.com/erikras/potionoceanErik Rasmussen – @erikras
Spells Cast•Split a long form into many smaller ones•Eased user cognitive load•Changedflow based on answers given•Flexible, robust logic•Easy to show to non-technical team membersErik Rasmussen – @erikrasFlow
Erik Rasmussen – @erikrasCenteredcentered.app
Erik Rasmussen – @erikrasOne month free – Premium Servicecentered.appDiscount Code:SHIFT