[英]enabled and disabled button with select picker react native
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. 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.
React 限制了渲染的数量以防止无限循环。
Try this way试试这个方法
const [isDisabled, setDisabled] = useState(true);
const getctg2 = (val) => {
setDisabled( val =="please select" );
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.