Ask questions[react-hooks/exhaustive-deps] function outside the hook

Hi! I have some problems with [react-hooks/exhaustive-deps] rule of eslint. Can you help me, please?

Снимок экрана 2020-04-08 в 18 55 09

I have some effect, which to call function. Linter tells me that I should add getData to dependency. But I do not want my effect to depend on the function. I will have to wrap it in useCallback which may have its own dependency.

Снимок экрана 2020-04-08 в 18 55 57

I need my useEffect hook to be called only 1 time. But in this case, it will be called whenever id changes. How do I get around this behavior?

I have seen advice to put a function inside a hook, but this is not my case. I have to call this function from different hooks.


Answer questions vkurchatkin

You are free to ignore linter if that's what you want


Related questions

Disable react strict mode on third party libraries hot 6
Refs - "object is not extensible" hot 4
Warning: Unknown DOM property for. Did you mean htmlFor? hot 4
React@16.9 block `javascript:void(0);` hot 4
TypeError: Object(...) is not a function hot 3
Warning: validateDOMNesting(...): <tr> cannot appear as a child of <table> hot 3
React custom hook "Should have a queue. This is likely a bug in React" error message. hot 2
useEffect causes 'callback is not a function' exception hot 2
DevTools: Updating state or props in devtools does not trigger component update. hot 2
Infinite loop in useEffect using blank object or array hot 2
False-positive security precaution warning (`javascript:` URLs) hot 2
Hooks API - hook breaks when exported from module hot 2
Function components do not support contextType. hot 2
Feedback on useEffect depndencies change error hot 2
[ESLint] Feedback for 'exhaustive-deps' lint rule hot 2
Github User Rank List