I have a pretty simple react component with several states. One of them it behaving weirdly.
for example, the following code snippet works fine
const [showError, setShowError] = useState(false);
function makeNewDevisTaskForm() {
// set to true for simplicity
if (true) {
setShowError(true);
} else {
// setShowError(false);
}
}
this fails ! The error message says: setShowError is not a function
const [showError, setShowError] = useState(false);
function makeNewDevisTaskForm() {
// set to true for simplicity
if (true) {
setShowError(true);
} else {
setShowError(false); // throw error 'setShowError is not a function'
}
}
So, I just can’t get what’s wrong. My setShowError works in the if statement but fails in the else !