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

map obj as shallowRef() instead of ref() #193

Closed
kor3k opened this issue Oct 11, 2024 · 1 comment
Closed

map obj as shallowRef() instead of ref() #193

kor3k opened this issue Oct 11, 2024 · 1 comment

Comments

@kor3k
Copy link
Contributor

kor3k commented Oct 11, 2024

https://github.com/studiometa/vue-mapbox-gl/blob/develop/packages/vue-mapbox-gl/components/MapboxMap.vue#L308

const map = ref();
// should rather be
const map = shallowRef();

https://vuejs.org/api/reactivity-advanced.html#shallowref

Unlike ref(), the inner value of a shallow ref is stored and exposed as-is, and will not be made deeply reactive. Only the .value access is reactive.
shallowRef() is typically used for performance optimizations of large data structures, or integration with external state management systems.


i believe the map object should be wrapped with shallowRef() instead of ref(), as no inner state is being watched, just .value.

@kor3k kor3k mentioned this issue Oct 13, 2024
@titouanmathis
Copy link
Collaborator

#194 has been merged and will be included in the next release, thanks for your contribution @kor3k!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants