I can turn that rule of for entire array:
useEffect(() => {
if (id) {
stableCallback(id);
dynamicCallback(id);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [id, dynamicCallback]);
But my preference would be to achieve something along these lines (pseudocode):
useEffect(() => {
if (id) {
stableCallback(id);
dynamicCallback(id);
}
// eslint-disable-next-line react-hooks/exhaustive-deps stableCallback
}, [id, dynamicCallback]);
In my imagination, the usage of "stableCallback" does not trigger the warning, but if a new dependency emerges within it, I will see the warning about it (I know that if stableCallback
is not changed then it should not matter - but that's only an example).
Is there a rule similar to exhaustive-deps, or any alternative approach that would allow me to utilize it in a similar manner?
I haven't found any alternative to it.