react/packages/eslint-plugin-react-hooks/__tests__
João Eirinha 2381ecc290
[ESLint] Disallow passing effect event down when inlined as a prop (#34820)
## Summary

Fixes https://github.com/facebook/react/issues/34793.

We are allowing passing down effect events when they are inlined as a
prop.

```
<Child onClick={useEffectEvent(...)} />
```

This seems like a case that someone not familiar with `useEffectEvent`'s
purpose could fall for so this PR introduces logic to disallow its
usage.

An alternative implementation would be to modify the name and function
of `recordAllUseEffectEventFunctions` to record all `useEffectEvent`
instances either assigned to a variable or not, but this seems clearer.
Or we could also specifically disallow its usage inside JSX. Feel free
to suggest any improvements.

## How did you test this change?

- Added a new test in
`packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js`.
All tests pass.
2025-10-16 14:18:01 -04:00
..
ESLintRuleExhaustiveDeps-test.js [lint] Remove experimental gating useEffectEvent rules (#34660) 2025-09-30 16:55:56 -04:00
ESLintRulesOfHooks-test.js [ESLint] Disallow passing effect event down when inlined as a prop (#34820) 2025-10-16 14:18:01 -04:00
ReactCompilerRuleTypescript-test.ts [compiler] Derive ErrorSeverity from ErrorCategory (#34401) 2025-09-06 12:41:29 -04:00