Skip to content

Bug: rules-of-hooks violation not caught by eslint plugin #22520

@pke

Description

@pke

Given the following code:

const createHandler = () => (event) => {
  const { t } = useTranslation()

  Alert.alert(t("title"), t("message"))
}

function MyComponent() {
  return <Button onPress={createHandler()}/>
}

the rules-of-hooks linter rule is not triggered for the createHandler as it should.
The linter rule should detect its not a react component, since it does not return any ReactElement or null.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions