I've got a "select" component that selects the number of forms I want to display below. The form is a single component and I want to reuse it. It needs do have an independent state so I can use how many fields I want for the same form (an array of fields). Any hints about How can I render this component multiple please?
const indexes = [1, 2, 3];
const MyComponent = () => {
const [numberOfUnits, setNumberOfUnits] = useState(1);
const Form = () => <p>my form</p>;
return (
<select onChange={e => setNumberOfUnits(e.target.value)}>
{indexes.map(index => (
<option key={index} value={index}>
{index}
</option>
))}
</select>
//Here I should render X (numberOfUnits) amount of times of the Form component
);
};