Reset variable reactive #6519
Unanswered
JCauz
asked this question in
Help/Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm having a problem with something that's actually quite simple. I have a compose which allows to create or modify an element by opening a modal to display the form.
So I have a props which is not mandatory with a default value (a class instance). I initialize a variable in the setup and I give the default value. After modification, I save and therefore via an emit I send the element. But the problem is that when I open the modal again the fields stay filled with the data from the last item to send. Worse, the element that the parent to retrieve is changed if I modify in the modal.
I wanted to use the code:
Object.assign(Object.create(Object.getPrototypeOf(myClass)), myClass)
To initialize the variable in the setup script and the same in the computed when the viable to close the modal is false I redo a
myVar = reactive(Object.assign(Object.create(Object.getPrototypeOf(props.initMyVar)), props.initMyVar))
I also did this for the emit.
But when I reopen the parent element is no longer modified, but nothing reacts properly.
Do you have an idea ?
I note that I am trying to reset with a js class instance not an object.
Thanks a lot for your help
Beta Was this translation helpful? Give feedback.
All reactions