mirror of
https://github.com/zebrajr/react.git
synced 2025-12-07 12:20:38 +01:00
## 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. |
||
|---|---|---|
| .. | ||
| ESLintRuleExhaustiveDeps-test.js | ||
| ESLintRulesOfHooks-test.js | ||
| ReactCompilerRuleTypescript-test.ts | ||