In my reactjs application in which I have a functional component and completed is a state and it is defined as below using hooks.
const [completed, setCompleted] = useState(false)
Question 1:
When component renders for the first time i want to invoke a parameterized function checkEmpty without arguments inside useEffect as below. This checkEmpty function will return a boolean value. But the function below is not getting triggered inside useEffect. I want to make the code to invoke checkEmpty function and if it returns true the completed state should set to true.
useEffect(() => {
checkEmpty && setCompleted(true)
}, [])
Question 2:
In the below code in onChange event i'm trying to invoke two function. I want to start the checkEmpty function only after the setValue function completes
onChange={ value=> {
setValue(index, value),
checkEmpty(value, index)
}}
Can anyone please help to solve the same.