What is a good pattern for entity editor components #10742
Unanswered
franck102
asked this question in
Help/Questions
Replies: 2 comments 4 replies
-
I just re-read the docs to make sure I hadn't missed something obvious, and they have this to say ()::
Isn't this just a plain wrong solution? AFAIK the setup function will only be executed once so if/when the component is re-rendered or reused the local counter ref will not be updated? Franck |
Beta Was this translation helpful? Give feedback.
2 replies
-
IMO this is the correct case for a watcher.
This is good question and I would like to read some different opinions. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all, I have been using Vue 3 for a couple years, I read hundreds of posts & articles on the topic and I still cannot figure this out: what is the best pattern in Vue for an editor component that is responsible for editing an entity passed as a prop by its parent?
If trying to stick to the docs guidelines I don't want to modify the object passed by the parent, so I need to make a copy... and the key question is how to make sure that that copy is properly initialized in all situations (re-render, component instance being reused)... I have been bitten more than once by an editor displaying stale value from a different / previous entity.
The best I've come up with so far is something like this, but it doesn't feel right to have to use watch to handle that very common use case; I am aware of onUpdated, would that be better?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions