Skip to content

[eslint-plugin-react-hooks] false positive with useFocusEffect #18888

@leethree

Description

@leethree

Upgraded eslint-plugin-react-hooks to 4.0.0, it's showing errors on React-Navigation's useFocusEffect hook.

import { useFocusEffect } from '@react-navigation/native';

  useFocusEffect(
    React.useCallback(() => {
      const unsubscribe = API.subscribe(userId, user => setUser(user));
      return () => unsubscribe();
    }, [userId])
  );

(example copied from React-Navigation documentation)

The current behavior

Lint error:

React Hook useFocusEffect received a function whose dependencies are unknown. Pass an inline function instead.

The expected behavior

The rules shouldn't check the function because it's not a React useEffect hook.

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