enabled and disabled button with select picker react native

290 views Asked by At

when the select value is equal to the first select = 'please select' i want to disable the button and enable it the inverse when i select.

const [isDisabled, setDisabled] = useState(true);


const handleChangeButton =() => { 
setDisabled(false);
}
const getctg2 = (val) => { 
if (val !="please select "){
handleChangeButton();
}

}

the error msg that i have is : Error: Too many re-renders. React limits the number of renders to prevent an infinite loop.

1

There are 1 answers

2
Nooruddin Lakhani On

Try this way

const [isDisabled, setDisabled] = useState(true);

const getctg2 = (val) => {
  setDisabled( val =="please select" );
}