I have gone through the useEffect documentation and I do not understand why I get warning for every variable and function that I use inside useEffect, but I have no dependency on them.
Consider my useEffect here
const [updatedComm, setUpdatedComm] = useState<ICommunication>(props.comm)
const [isEditOn, setIsEditOn] = useState<boolean | false>(false)
const getPublishedComm = () => { /* function implementation */ }
const dispatch = useDispatch();
useEffect(() => {
if (!isEditOn && updatedComm !== props.comm) {
const publishedComm = getPublishedComm()
dispatch(editCommunication(publishedComm))
setCurrentComm(publishedComm)
}
}, [isEditOn])
My only need to run this effect is when isEditOn changes. However, this code logs warnings
Line 66:8: React Hook useEffect has missing dependencies: 'dispatch', 'getPublishedComm', 'props.comm', and 'updatedComm'. Either include them or remove the dependency array react-hooks/exhaustive-deps
What can I do to remove these warnings, or am I really missing something fundamentally?
Please help me understand.
Thank you