
[React, TS, Formik + Yup, Vite, styled] Multi Step Form
Design comparison
Solution retrospective
First, I made a custom input mask for a phone number without resorting to ready-made solutions from libraries. I also tried my hand at working with regular expressions.
Second, I worked firstly with multi-step forms. I wrote a custom hook for indexing and transition to other pages.
When the challenge was coming to an end, I found out that in the Formik repository in the examples
folder, there are several more multi-step form implementations. And you can't find these examples on the official docs page. Ah, how I wish I had this information earlier. :,)
The difficulties were with the input mask, with regular expressions, with validation of each page as you move through the form. It turned out that Formik supports hot-swapping of validation schemes, so I solved this problem.
What specific areas of your project would you like help with?In my implementation inside the render of the MultiStepForm component, I use Formik, which follows the construct:
{(formikProps) => ( MultiStepFormFields {...formikProps} currentStepIndex={currentStepIndex} goTo={goTo} next={next} back={back} pagesCount={pagesCount} )}
I would certainly prefer to pass MultiStepFormFields only as a prop component
in Formik and not clutter up extra lines of code. I ended up limiting myself with my custom hook, now the page index has to be passed from component to component. I came across another implementation in YouTube that seems to get rid of this limitation. But I'm running out of time to try it, should move next.
Please log in to post a comment
Log in with GitHubCommunity feedback
- @dylan-dot-c
Well done completing this challenge!
In terms of design most things look alright.
I noticed a few things that could be better
- I'm using MSedge and it seems like on some containers there are some disabled scrollbars all over the form, some are at the labels and the summary container, it could be the overflow scroll you have there and I must ask why. Anyways you could set it to overflow auto so it will only show the scrollbar when there is actually more content there to scroll.
- I see you made the button disabled before the form has been filled out, nothing is wrong and I don't know which is better, pressing the button and seeing required errors or seeing a disabled button and trying to figure out why it's disabled(take it with a grain of salt cause I'm not good enough either way)
- I made this mistake on my solution and I have yet to fixed it(too lazy) but when they reach the summary page, the change button could just automatically change the plan instead of having the user doing it manually.
Other than that everything seems to be alright
I also did this challenge with React, Zustand, TS, TailwindCSS and framer motion, I would appreciate it if you could check it out. I haven't used formik or yup before and I try to stay on a low level of abstraction for some of these challenges as it helps you to figure out how some of these work on a lower level
Anyways take care
Join our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord