Git Product home page Git Product logo

fem-multi-step-form's Introduction

Frontend Mentor - Multi-step form solution

This is a solution to the Multi-step form challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

Table of contents

Overview

The challenge

Users should be able to:

  • Complete each step of the sequence
  • Go back to a previous step to update their selections
  • See a summary of their selections on the final step and confirm their order
  • View the optimal layout for the interface depending on their device's screen size
  • See hover and focus states for all interactive elements on the page
  • Receive form validation messages if:
    • A field has been missed
    • The email address is not formatted correctly
    • A step is submitted, but no selection has been made

Screenshot

Mobile

fem-multi-step-form netlify app_(iPhone SE)

Desktop

fem-multi-step-form netlify app_(Nest Hub Max)

Links

My process

Built with

  • Semantic HTML5 markup
  • CSS custom properties
  • CSS Flexbox
  • CSS Grid
  • TypeScript
  • React
  • Redux Toolkit

Notes

The main challenge for this project was managing states across multiple components. To avoid prop drilling, I originally implemented React's built-in useContext hook to hold these states. But since every new component consumes from the same context, the growing number of states to track and manage became an issue. Moreover, since all the components were nested within the same context provider, every single state change triggered every mounted component to re-render. This was especially pronounced when typing into form fields since every single key press triggered unrelated components to unnecessarily re-render.

For both performance reasons and my personal impulse to minimize component re-renders, I refactored the project using Redux Toolkit, a robust state manager, which is easier to use than Redux as it abstracts away much of Redux's boilerplate code. Redux Toolkit's createSlice feature was particularly useful for modularizing different states and their respective reducers. In addition to more organized code, components now re-render only when its subscribed states have changed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.