-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
fix(utils): make useId SSR friendly #1731
Conversation
Run & review this pull request in StackBlitz Codeflow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll need to think about this. While fixing a different issue for SSR, you've also introduced a https://vuejs.org/guide/scaling-up/ssr.html#cross-request-state-pollution
Regardless, it has other issues such as the debugger and isn't reactive
Thank you for quick reply. I've fixed debugger. If no Please indicate what other issues you see here. |
Nuxt 3.10 just released with an SSR friendly For Non-Nuxt users, something similar is expected in Vue 3.5 (but i dont know the timetable). |
Just gotta fix the build issues then I'll merge |
I've fixed tests. Please, review again. |
I double checked build. It should be green now. |
Depending on the outcome of Vue 3.5, we may have a builtin composable for this 👀 Perhaps we should simply wait for the official tool first? (With high hopes I suppose, 3.5 may or may not include that change. I'm not mind reader) It's up to you though. It just looks like a lot of this code is a bit hacky. (nextTicks here and there waiting for things to happen 🤮) I assume the official Vue version would implement SSR protection (as if it didn't, then there would be no actual need for the composable). Idk, just seems like a lot to have a stable id rn |
Closing in favor of #1836 |
Describe the PR
If component id is not explicitly specified, it is generated using Math.random(), which leads to hydration errors:
Solution: use the bootstrap-vue strategy. If the component id is not specified, leave it empty during SSR and generate it
onMounted
.Fixes: #1730
Small replication
A small replication or video walkthrough can help demonstrate the changes made. This is optional, but can help observe the intended changes. A mentioned issue that contains a replication also works.
PR checklist
What kind of change does this PR introduce? (check at least one)
fix(...)
feat(...)
fix(...)
docs(...)
The PR fulfills these requirements:
CHANGELOG
is generated from these messages, and determines the next version type. Pull requests that do not follow conventional commits or do not have an override will be denied