Skip to content

Bug: react-hooks/rules-of-hooks does not error when useEffectEvent is passed down when inlined in a prop #34793

@jf-eirinha

Description

@jf-eirinha

eslint-plugin-react-hooks is not detecting a useEffectEvent usage violation when it is used inline (i.e. not reassigned to a variable).

React version: 19.2.0
eslint-plugin-react-hooks version: 7.0.0

Steps To Reproduce

Code example:

import { useEffectEvent } from "react";

function App() {
  // ❌ should throw error. Effect event can't be passed down.
  return <Component cb={useEffectEvent(() => {})} />;
}

function Component() {
  return <></>;
}

The current behavior

Linter gives no error.

The expected behavior

Linter gives an error disallowing useEffectEvent callback from being passed down.

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