Submitted 4 months agoA solution to the Multi-step form challenge
Multi-Step Form built with Next.js, Mantine, TypeScript, and Zustand
next, typescript, zustand, post-css
@gellend

Solution retrospective
What are you most proud of, and what would you do differently next time?
-
Most Proud Of:
- Successfully implementing a functional multi-step form with client-side routing (Next.js App Router) and global state management (Zustand).
- Successful integration between Next.js and Mantine, including initial theming setup and
ColorSchemeScript
to address hydration issues. - Implementation of an organized directory structure for components, store, and types.
- Resolving bugs related to Zustand state management ("Maximum update depth exceeded" and "getSnapshot should be cached") by correcting selector patterns.
- Creating a responsive
Sidebar
component that matches the reference design, including the use of background images and active step indicators. - Implementation of basic form validation using
@mantine/form
.
-
Do Differently Next Time:
- Perhaps define the global color scheme (CSS variables) earlier in the process for consistency and to avoid using direct HSL values in some places initially.
- Consider creating a more comprehensive type system for all form data and component props from the outset.
- Explore further optimizations for
useEffect
in synchronizing the form with the store, although the current solution is functional.
- Initial Mantine & Next.js Setup: Encountered a hydration error related to
data-mantine-color-scheme
. This was resolved by addingmantineHtmlProps
to the<html>
tag andColorSchemeScript
inapp/layout.tsx
. - State Management with Zustand: Faced "Maximum update depth exceeded" and "getSnapshot should be cached" errors in several form step components. This issue was identified as stemming from how Zustand selectors were fetching state (fetching the entire state object caused excessive re-renders) and was fixed by changing selectors to only retrieve relevant state portions individually.
- Styling and Design Consistency: Required several iterations to adjust component styling (like
Sidebar
, input fields, buttons) to matchstyle-guide.md
and visual references, including the implementation of active states. This involved using CSS variables, Mantine'sstyles
props, and CSS Modules. - Navigation and Next.js
Link
Component Props: There was an error related tolegacyBehavior
on the Next.jsLink
component inSummaryStep.tsx
, which was resolved by removing the prop. - Form Synchronization with Store: There was some difficulty ensuring
useEffect
inSelectPlanStep.tsx
ran with the correct dependencies to synchronize form state with the Zustand store without triggering unnecessary loops.
Currently, the main focus is on adjusting the design for mobile view and ensuring all colors and active states fully align with style-guide.md
throughout the application.
- Review of the current styling implementation, especially the use of Mantine's
styles
prop versus CSS Modules for more complex cases (e.g., very specific hover states on buttons). - Suggestions for best practices in handling responsiveness with Mantine across various form components.
- Perhaps feedback on the accessibility of the created form.
Code
Loading...
Please log in to post a comment
Log in with GitHubCommunity feedback
No feedback yet. Be the first to give feedback on Gellen's solution.
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