Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ESLint] Add test for rejected useId in async Components #31208

Merged
merged 2 commits into from
Oct 15, 2024

Conversation

eps1lon
Copy link
Collaborator

@eps1lon eps1lon commented Oct 13, 2024

Summary

Just added tests to make it clear useId being disallowed in async Components is intentional.

useId is allowed in Server Components. However, it doesn't work after await so we shouldn't allow it in async functions. We'd also disallow it if it's wrapped in a custom hook because we can't know whether the hook is stateful.

useId does work in shared components. Shared components cannot be async.

`useId` is the only Hook allowed in React Server Components so it should be allowed in async functions.
Copy link

vercel bot commented Oct 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 15, 2024 1:24pm

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Oct 13, 2024
@react-sizebot
Copy link

react-sizebot commented Oct 13, 2024

Comparing: c7c68ef...e991083

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.js = 6.68 kB 6.68 kB = 1.82 kB 1.82 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 506.33 kB 506.33 kB = 90.58 kB 90.58 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 511.26 kB 511.26 kB = 91.30 kB 91.30 kB
facebook-www/ReactDOM-prod.classic.js = 603.42 kB 603.42 kB = 106.73 kB 106.73 kB
facebook-www/ReactDOM-prod.modern.js = 579.61 kB 579.61 kB = 102.82 kB 102.82 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against 6a590b6

@eps1lon eps1lon changed the title [ESLint] Allow useId in async functions [ESLint] Add test for rejected useId in async Components Oct 15, 2024
@eps1lon eps1lon merged commit 8382581 into facebook:main Oct 15, 2024
184 checks passed
@eps1lon eps1lon deleted the sebbie/async-component-hooks branch October 15, 2024 15:17
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.

4 participants