Comment by tipiirai
2 years ago
Keys are unnecessary in Nue, just like many, many other framework abstractions. If you receive another list from the server, Nue takes care of it automatically. No need for diffing.
2 years ago
Keys are unnecessary in Nue, just like many, many other framework abstractions. If you receive another list from the server, Nue takes care of it automatically. No need for diffing.
https://github.com/nuejs/nuejs/blob/a5c844494852cdbe3282fdc5...
Am I correctly reading that you just throw away and re-render the entire DOM?
"Keys are unnecessary" in what way? The only reason they are necessary in React etc. is to keep DOM mutations to a minimum. Are keys unnecessary because you always re-render the whole list, making for very inefficient updates?
True. When the array changed, the view is indeed re-rendered. Nue is probably not a good pick ATM for UI's with hundreds of rows and when list re-rendering performance is critical. I'll add the key- support if this becomes a frequent issue.
It's not just about performance, although that is of course a big part. What if I have child components with state that I don't want re-rendered? Suddenly I have to track the state in the parent to keep it from disappearing on every array change.
This has big architectural implications, and it worries me a bit that you only see it as relevant for benchmarks.
> if this becomes a frequent issue
This becomes a frequent issue in any app at scale.
If your app is at a small enough scale that it doesn't run into this issue, I would not recommend using a framework: just use vanillajs &/or some modular utility components.
If you're working on a small app & want to do it in a framework because you anticipate scale, use one with key support.
13 replies →