I have array list i.e
const data = [
{
title: 'Title1',
},
{
title: 'Title2',
},
{
title: 'Title3',
},
{
title: 'Title4',
},
];
that needs to be render inside Modal along with the Next and Previous button I can achieve using Switch Case , seems like this not a feasible solution.
any idea how to render title and when the user click on Next button it should change the content also. here is my switch case solution.
const [showStep, setShowStep] = useState(1);
const renderModal = () => {
switch (showStep) {
case 1:
return (
<Modal
open={show}
onClose={() => setShow(false)}
onSubmit={() => setShowStep(2)}
title={'User Type'}
number={1}
total={3}
/>
);
case 2:
return (
<Modal
open={show}
onClose={() => setShow(false)}
onSubmit={() => setShowStep(3)}
title={'UserClass'}
number={2}
total={3}
previous={
<ButtonComponent
onClick={() => setShowStep(1)}
name={'Previous'}
color={'primary'}
variant={'outlined'}
/>
}
/>
);
case 3:
return (
<Modal
open={show}
onClose={() => setShow(false)}
onSubmit={() => setShowStep(4)}
title={'Class'}
number={3}
total={3}
previous={
<ButtonComponent
onClick={() => setShowStep(2)}
name={'Previous'}
color={'primary'}
variant={'outlined'}
/>
}
/>
);
default:
return null;
}
}