I know the how useEffect's dependencies works. However in my scenario, I should not watch the change of a prop value I use it as a condition to process flow, but I will get a react-hooks/exhaustive-deps warning if I don't put it in the dependencies array.
My scenario is that if foo and fetchValue change, I want to re-run the whole fetch. Although I use bar as a condition to decide is the fechValue called, but in my business logic, the change of bar should not make re-run the block.
const Component = ({ foo, bar, fetchValue }) => {
useEffect = (
() => {
if(foo) {
if (bar) {
fetchValue();
}
}
},
[foo, fetchValue] // will get a warning `react-hooks/exhaustive-deps`
)
return <div />
}