question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug [ESLint Hooks Plugin]: When using a `typeof` type guard it requires the value as a dependency

See original GitHub issue

Version: eslint-plugin-react-hooks@1.7.0

Steps To Reproduce

  1. Create a component with local state
  2. Create a useEffect with a variable inside, that points to the typeof of the state variable

Link to code example:

https://codesandbox.io/s/nervous-williamson-2i99l?file=/src/App.tsx:210-261

The current behavior

react-exhaustive-deps complains that the state variable should be included in the dependency list

The expected behavior

react-exhaustive-deps shouldn’t complain that the state variable should be included in the dependency list because it’s value is never used.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
gaearoncommented, Jul 8, 2020

@delca85 Please go ahead, it’s been a while!

0reactions
gaearoncommented, Jul 13, 2020

@delca85 fixed this in #19316. If you find other similar issues, please report them too! Thanks.

eslint-plugin-react-hooks@4.0.8 should have the fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why eslint-plugin-react-hooks doesn't warn when using react ...
I added the following dependencies: @typescript-eslint/eslint-plugin and @typescript-eslint/parser to package.json and added the following to .eslintrc.js :
Read more >
Design Patterns with React Easy State | by Bertalan Miklos
Easy State is a practical Proxy-based state management library for React. Learn how to create applications with it through an app, which pairs...
Read more >
eslint-config-torchbox - npm
Shareable ESLint config following Torchbox's code style. ... Start using eslint-config-torchbox in your project by running `npm i eslint-config-torchbox`.
Read more >
eslint | Yarn - Package Manager
ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code. In many ways, it is similar to JSLint and...
Read more >
CoffeeScript
coffee script into a .js JavaScript file of the same name. -t, --transpile, Pipe the CoffeeScript compiler's output through Babel before saving ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found