I have an input element returned by an Array of strings like the image below. How can I write the input component so that the subsequent inputs are disabled until the current input is entered by the user? Users can only start with the input from the top left then move to the right accordingly.
function() {
return (
<div>
{strArr.map((item, index) => (
<input />
))}
</div>
)}
Thanks for your help!
function() {
const [isActive, setIsActive] = React.useState(0);
const handleOnInputChange = (index)=>{
setIsActive(index+1)
}
return (
<div>
{strArr.map((item, index) => (
<input ket={index} id={index} disabled={isActive !== index} onChange={()=>handleOnInputChange(index)}/>
))}
</div>
)}