@saberduck if you’re talking about the OP his screenshot does show why.
He has a onClick
which is taking goToPreviousStep
which is a standalone function. Since it’s a standalone function it should trigger the violation.
For him to fix it he just needs to wrap it
const goToPreviousStep = useCallback(function goToPreviousStep() {
setActiveStep(activeStep - 1, []);
}
It’s a tedious fix but it is a valid violation.
Side note
Actually I have to correct myself earlier. I was mistaken that it memoizes the result. Looking more closely at Hooks API Reference – React (reactjs.org) it states it memoizes the callback which means you don’t need to do the useMemo(()=>()=>{...}, [])
Which BTW may be a good violation to track
Something like
useMemo(()=> () => {...}, []);
should be written as
useCallback(() => {...}, []);