import React, { useState } from 'react';
const MyComponent = () => {
const [numOfInputs, setNumOfInputs] = useState(0);
const handleNumOfInputsChange = (event) => {
setNumOfInputs(event.target.value);
};
const inputArray = Array.from({ length: numOfInputs }, (_, index) => index + 1);
return (
<div>
<input type="number" value={numOfInputs} onChange={handleNumOfInputsChange} />
{inputArray.map((inputNum) => (
<input key={inputNum} type="text" />
))}
</div>
);
};
export default MyComponent;