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

initial-model not reacting to new data #323

Open
moyalmic opened this issue Feb 18, 2024 · 2 comments
Open

initial-model not reacting to new data #323

moyalmic opened this issue Feb 18, 2024 · 2 comments
Labels
question Further information is requested

Comments

@moyalmic
Copy link

Version is v5.2.2

I'm trying to create a reactive array that would cause the tree view to update every time the data changes but i'm having trouble getting the component to refresh. I've created a computed value called files that maps strings to nodes (giving it a unique id) and when I create a list object using v-for, the list updates properly, but I can't get the tree-view component to update itself with the new data.
image

Could somebody please tell me what i'm doing wrong? Does initial-model not update after being set once? Please help me out!
Many thanks!

@moyalmic moyalmic added the question Further information is requested label Feb 18, 2024
@grapoza
Copy link
Owner

grapoza commented Feb 18, 2024

Hey @moyalmic , I've been trying to set up a StackBlitz for this but apparently the internet is even slower than I thought here and pages keep timing out on me. I never thought I would miss the internet this much... :)

The initial computed value is only applied once in this case because the actual computed value that is initially set changes. If it was a ref instead of a computed and you used a watch to update the ref's value then the tree would see those updates (because that ref object isn't changing, just it's value). I'm hoping that makes sense; this is where the actual example would have been helpful.

@moyalmic
Copy link
Author

moyalmic commented Feb 19, 2024

It does make sense, I've tried rewriting it using a ref and a watch and again, it seems to be updating correctly when I debug it and log the resulting list to the console, but the tree itself isn't changing reactively :(
image

Also the first comment under this Stack Overflow post says it's discouraged to use watch in favor of computed properties (especially on arrays which I am doing here)...

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

No branches or pull requests

2 participants