Skip to content

docs: add addendum on useId usage with computed #3262

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

Merged
merged 2 commits into from
Jul 15, 2025

Conversation

bencodezen
Copy link
Member

Description of Problem

There is currently no documentation around how useId() can cause errors in computed() due to conflicting instances.

Proposed Solution

Since this is something people will likely run into, a warning callout is proposed to help users avoid this problem going forward.

Additional Information

Copy link

netlify bot commented Jul 8, 2025

Deploy Preview for vuejs ready!

Name Link
🔨 Latest commit 516cbfb
🔍 Latest deploy log https://app.netlify.com/projects/vuejs/deploys/68769c3a6c3d5d0008edf4d5
😎 Deploy Preview https://deploy-preview-3262--vuejs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@bencodezen bencodezen added the content Issues / PRs related to docs content label Jul 8, 2025
@bencodezen bencodezen force-pushed the docs/add-warning-for-useid-in-computed branch from 1cc7db4 to 275c2cd Compare July 8, 2025 13:24
Copy link
Member

@brc-dd brc-dd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Though the ModelRef formatting can be reverted if prettier didn't update it 👀

@brc-dd
Copy link
Member

brc-dd commented Jul 8, 2025

Though more that I think, using useId with computed won't make much sense for anyone. Like if you have a static suffix/prefix, then why not just concat it const ariaDescribedBy = `${id}-description`. And if you don't have a static string, then why not use computed to generate a unique key from other refs/props. And if you don't have a unique static string, then why not just use useId alone. Maybe we should just remove the example 😅. The warning itself is fine.

@bencodezen bencodezen force-pushed the docs/add-warning-for-useid-in-computed branch from 5bb6d46 to 516cbfb Compare July 15, 2025 18:21
@bencodezen
Copy link
Member Author

Thanks for the review @brc-dd!

@bencodezen bencodezen merged commit 81d3626 into main Jul 15, 2025
4 of 5 checks passed
@bencodezen bencodezen deleted the docs/add-warning-for-useid-in-computed branch July 15, 2025 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Issues / PRs related to docs content
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants