I run into this more and more frequently in various forms: (simplified example)
const searchParameters = useState();
const sorting = useState();
// update searchParameters if the user enters someting
// update sorting if the user clicks on a column in the table
// PROBLEM: I only want to call loadEntries() if sorting changes, but I need searchParameters for it too!
useEffect(
() => loadEntries(sorting, searchParameters),
// eslint-disable-next-line react-hooks/exhaustive-deps
[sorting]
);
- Is there a way to deal with this situation without having to disable
react-hooks/exhaustive-deps?
- (less important) is there a way to disable
react-hooks/exhaustive-deps
for only a specific dependency? (searchParameters in this case)