Skip to content

[ESLint] Treat useEvent retval as stable#25121

Open
gaearon wants to merge 1 commit intofacebook:mainfrom
gaearon:useevent-lint
Open

[ESLint] Treat useEvent retval as stable#25121
gaearon wants to merge 1 commit intofacebook:mainfrom
gaearon:useevent-lint

Conversation

@gaearon
Copy link
Copy Markdown
Collaborator

@gaearon gaearon commented Aug 19, 2022

Seems like regardless of all other parts, this will still be true.
This would let me make the beta docs sandboxes working even if use a polyfill/stub.

I could maybe wrap this in EXPERIMENTAL so it's only active for experimental releases of the plugin?

@gaearon gaearon requested a review from sebmarkbage August 19, 2022 16:54
@facebook-github-bot facebook-github-bot added the React Core Team Opened by a member of the React Core Team label Aug 19, 2022
@sizebot
Copy link
Copy Markdown

sizebot commented Aug 19, 2022

Comparing: 19e9a4c...aed8c9b

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 134.28 kB 134.28 kB = 42.94 kB 42.94 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 140.35 kB 140.35 kB = 44.74 kB 44.74 kB
facebook-www/ReactDOM-prod.classic.js = 474.44 kB 474.44 kB = 84.88 kB 84.88 kB
facebook-www/ReactDOM-prod.modern.js = 459.68 kB 459.68 kB = 82.63 kB 82.63 kB
facebook-www/ReactDOMForked-prod.classic.js = 474.44 kB 474.44 kB = 84.88 kB 84.88 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js +0.26% 87.66 kB 87.88 kB +0.14% 20.81 kB 20.84 kB
oss-stable-semver/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js +0.26% 87.66 kB 87.88 kB +0.14% 20.81 kB 20.84 kB
oss-stable/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js +0.26% 87.66 kB 87.88 kB +0.14% 20.81 kB 20.84 kB

Generated by 🚫 dangerJS against aed8c9b

@nidhishgajjar
Copy link
Copy Markdown

Orb Code Review (powered by GLM 5.1 on Orb Cloud)

Review of PR #25121: [ESLint] Treat useEvent retval as stable

Summary

Adds useEvent return values to the exhaustive-deps rule's list of stable hook values, alongside useRef.

Observations

Correct change: useEvent by design returns a stable function reference that always accesses the latest props/state via closure. It should never need to be listed as a dependency in useEffect, useMemo, etc. The implementation correctly mirrors the existing useRef handling.

Test coverage: The new valid test case demonstrates the intended behavior — onStuff from useEvent used inside useEffect without being in the dependency array. This was previously a false positive.

No issues found. Clean, minimal change.

Summary: Correctly marks useEvent return values as stable in the exhaustive-deps lint rule, preventing false-positive warnings.

Assessment: approve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants