The following code gives the "useEffect has a missing dependency" error:
useEffect(() => {
inputToOutput();
}, [sortalphaStatus, sorttypeStatus]);
So I change it to this:
useEffect(() => {
inputToOutput();
}, [sortalphaStatus, sorttypeStatus, inputToOutput]);
But now I get this error: "The 'inputToOutput' function makes the dependencies of useEffect Hook (at line 363) change on every render. To fix this, wrap the definition of 'inputToOutput' in its own useCallback() Hook"
My function being called is in this format:
const inputToOutput = e => {
inputTextTmp = inputText;
blah blah;
};
I've no idea what to do about this. I wanted to use a callback function when setting state in my functional component but understand that is not possible, so I have used a useEffect hook. But now I get these errors that I cannot overcome.
Any suggestions?