Highlight missing hook dependencies

At some point Webstorm would highlight if a hook was missing dependencies.  It's no longer doing that.  I've been digging through the settings and I'm not seeing there that would goven this behavior.  What am I missing?  How can I get it so that I'm warned if depedencies are missing from my hooks?

Thank you!

Christoph

0

Unfortunately, it’s not quite clear what the problem is. Can you please describe it in more detail? Files or code snippets that reproduce the issue plus screenshots that show what it looks like on your end would be helpful.

0

Ok, here's an example

const a = 1;
const b = 2;
const sum = React.useMemo(() => {
  return a + b;
}, [a]);

As you can see, not all of the dependencies are in the dependency array – b is missing.  At one point it was the case that Webstorm would alert me to the fact that b was missing.  It doesn't do that any more and I can't figure out why.

I hope that helps!

Thanks!

Christoph

0

Thanks for clarification!

 

there are no built-in inspections for this. You must have used the ESLint eslint-plugin-react-hooks plugin, it has a rule for validating dependencies of React hooks.

0

My team has a eslint config file that I can't touch.  Is there a way to set this up just for me?  I see that there are items for additional rules or eslint options but I don't see examples on how to handle a situation like this.

Thank you!

0

I'm not sure how to do this. ESLint provides a way to extend existing configurations, but there doesn't seem to be any way to extend a local configuration file. I'd suggest submitting a question to https://github.com/eslint/eslint/issues.

0

请先登录再写评论。