-
-
Notifications
You must be signed in to change notification settings - Fork 186
perf: use shallowRef and useTemplateRef
#476
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
| const popupEl = ref<HTMLElement | null>(null) | ||
| const popupEl = useTemplateRef('popupEl') | ||
| const popupPosition = shallowRef<{ top: number; left: number } | null>(null) | ||
|
|
||
| // Function ref - captures the element when popup mounts | ||
| function setPopupRef(el: unknown) { | ||
| popupEl.value = (el as HTMLElement) || null | ||
| } | ||
|
|
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.
@Flo0806 was there a reason to use a setter here? from my tests conditional useTemplateRef works fine with onClickOutside 😅
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 had some problems, yes. But if it works for you - perfect. Your way is the better
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.
If you can still reproduce the bug we might be able to fix it upstream (vueuse or vue)
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.
No... I think I had just to restart the dev server...
|
we should create an eslint rule |
I also thought about this. I think we have an lint rule at vueuse that |
|
Not sure how to migrate this to oxlint |
Replacing some refs with shallowRefs