I have a useEffect hook look like this:
React.useEffect(() => {
// navigate from pdf to source
if (srcFocus && srcFocus.length > 0) {
let pos: SrcPosition = srcFocus[0];
let name_paths = pos.file.split("/");
ProjectTreeFolder.handleExpandFolder(
name_paths,
props,
selectedFile
);
}
}, [srcFocus, props]);
now I only want to trigger this effect when srcFocus
change, but the eslint always told me add selectedFile
to dependencies array.
what is the best practice if I really need triiger useEffect only when srcFocus
change? I am sure did not need to trigger the useEffect when props
or selectedFile
change. also did not want do disable the eslintreact-hooks/exhaustive-deps
check.