Mutating one prop recreates the whole window.xprops object
See original GitHub issueI am passing a number of properties from parent to the child (the child is an iframe). Some of the props are primitives, some are arrays of objects.
I noticed that when I mutate one prop (e.g. a primitive one) then the whole window.xprops
object is recreated, i.e. it becomes a completely new object. Since the child is a reactive app (Vue), rebuilding the array prop forces the child to rerender itself completely (the array contains data which is used to render some components). It would be best if props that are not explicitly mutated in the parent are not altered in window.xprops
on the child.
Is this by design or can it be fixed?
My setup: I am using the Vue driver in the parent, and passing the props as props of the Vue component, e.g.:
<my-comp :selected-element="selectedElement" :document="document" />
selectedElement
is a number and document
is a nested structure (array of objects with children).
So whenever selectedElement
is updated in the parent, this forces window.xprops.document
to be updated in the child as well, even though its contents are the same (it has not been changed in the parent).
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (1 by maintainers)
Top GitHub Comments
@ogulcantumdogan, sure. First, I have to note that I’m using Zoid with an iframe (not popup).
On the parent side I create the Zoid Vue component and store it in Vuex with code like this (here
createIframe
is a Vuex action):Then I have another Vue component (in the parent app) which I use as a wrapper for my Zoid component and to pass props and methods to the client Zoid component. Here is the
<template>
part of this Vue component:here
iframe
is the actual Zoid component that was created and stored in Vuex above. Note how I pass props and methods (e.g.handleEvent
) to the client but this is already well documented by the Zoid team.Then in the client Vue app I just call
zoid.create()
inApp.vue
:That’s pretty much it. Then, on the client, just use the code in my previous post if you need the reactivity.
Hope that helps. Good luck!
BTW, @bluepnume, did you have a chance to think on how to add this reactivity to Zoid?