Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

implementating step component in react

//1. Implementing 2 steps in Login using hashmap
// frontendsrcpagesLoginLogin.jsx

import StepPhoneEmail from '../Steps/StepPhoneEmail/StepPhoneEmail';
const steps = {
    1: StepPhoneEmail,
    2: StepOtp,
};

const Login = () => {
    const [step, setStep] = useState(1);
    //select component according to step 
    const Step = steps[step];

    function onNext() {
        setStep(step + 1);
    }

    return <Step onNext={onNext} />;
};
 
PREVIOUS NEXT
Tagged: #implementating #step #component #react
ADD COMMENT
Topic
Name
8+6 =