I've created this useEffect construct to first launch validation and then to POST the data if it passes validation:
const isFirstRun = useRef(true);
useEffect(() => {
if (isFirstRun.current) {
isFirstRun.current = false;
return;
}
if (isProcessing) {
validate();
} else {
if (_.isEmpty(validationErrors)) {
console.log('*** Ready to POST ***');
}
}
}, [isProcessing]);
I'm entirely fine with having just isProcessing as the only dependency for the useEffect but the VSCode linter is insisting that validate and validationErrors also be included.
I'm sure that adding validate would cause no problems but given that the validation code keeps adding items to validationErrors, I don't want this useEffect triggered every time it's changed.
How would you handle this situation?