Skip to content

Bug: eslint-plugin-react-hooks exhaustive-deps rule shouldn't warn when using an object's property #28316

@julienw

Description

@julienw

eslint-plugin-react-hooks version: 4.6.0

Example code:

import { useCallback } from "react";
import { useFetcher } from "react-router-dom";

...
    const fetcher = useFetcher();
    const onClick = useCallback(() => fetcher.submit(XXX), [fetcher.submit]);
    //  warning  React Hook useCallback has a missing dependency: 'fetcher'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

This is the recommended way of specifying the dependency for this method, see remix-run/react-router#10336.

Expected

There's no warning.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions