Skip to content

[react-hooks/exhaustive-deps] function outside the hook #18541

@eshturman

Description

@eshturman

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions