-
Notifications
You must be signed in to change notification settings - Fork 161
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: populate useState reactively in devtools #663
base: main
Are you sure you want to change the base?
fix: populate useState reactively in devtools #663
Conversation
any update here? |
I don't think we should clone the data and update the clone eagerly - it would be very inefficient and could cost extra memory. The root cause is that we didn't properly trigger the data when they updates, but also because we are dealing with multiple Vue instances (one in host, one in devtools, where watching on a forgien reactive object won't triggers properly. I think this would need a fix with another approach |
82a571e
to
6de1e7b
Compare
@antfu, I've made it possible to update only the necessary nested properties using the |
@@ -11,7 +13,7 @@ definePageMeta({ | |||
}) | |||
|
|||
const client = useClient() | |||
const payload = computed(() => client.value?.nuxt.payload) | |||
const payload = computed<NuxtPayload>(() => JSON.parse(JSON.stringify(client.value?.nuxt.payload))) |
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 think still, I would avoid this cloning, as it
- duplicate the object, doubles the memory usage (could even crash when payload is too big)
- doesn't handle the circular references
- losing the details when serializing a class or special objects
- it not always reflecting to the real data, sometimes could cause confusing on debugging
6de1e7b
to
be7301b
Compare
@antfu I've removed cloning. I've used |
be7301b
to
5ff0777
Compare
5ff0777
to
bc6b0cb
Compare
Looks great; I will test it a bit. Thanks a lot for being patient on this! |
bc6b0cb
to
723ff23
Compare
…te useState reactively (nuxt#643)
723ff23
to
7f10b8e
Compare
I looked into it, but it seems that using |
I left a comment here. |
fixes #643