slorber / react-async-hook

React hook to handle any async operation in React components, and prevent race conditions
https://sebastienlorber.com/handling-api-request-race-conditions-in-react
1.18k stars 44 forks source link

Tslint warnings #14

Open cruiserkernan opened 4 years ago

cruiserkernan commented 4 years ago

Hi

We have strict tslint/eslint rules and noticed that the react-async-hook code produces these warnings.

  Line 126:  React Hook useCallback has a missing dependency: 'options'. Either include it or remove the dependency array. If 'setValue' needs the current value of 'options', you can also switch to useReducer instead of useState and read 'options' in the reducer  react-hooks/exhaustive-deps
  Line 132:   React Hook useCallback has a missing dependency: 'options'. Either include it or remove the dependency array. If 'setValue' needs the current value of 'options', you can also switch to useReducer instead of useState and read 'options' in the reducer  react-hooks/exhaustive-deps
  Line 137:   React Hook useCallback has a missing dependency: 'options'. Either include it or remove the dependency array. If 'setValue' needs the current value of 'options', you can also switch to useReducer instead of useState and read 'options' in the reducer  react-hooks/exhaustive-deps
  Line 249:   React Hook useEffect was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies
               react-hooks/exhaustive-deps
  Line 249:   React Hook useEffect has missing dependencies: 'executeAsyncOperation', 'isMounting', 'normalizedOptions.executeOnMount', 'normalizedOptions.executeOnUpdate', and 'params'. Either include them or remove the dependency array
               react-hooks/exhaustive-deps

Is it save to include the dependencies that are missing or will that cause unexpected behaviour?

Thanks /Martin

slorber commented 4 years ago

thanks for reporting this

I often don't follow this eslint rule, you can check https://github.com/facebook/react/issues/16956 to understand why. Will consider finding another option if needed

BTW how it comes your tslint setup does check library code, isn't it supposed to only check your own code?