Replies: 3 comments
-
@gjmcn here (in your two commented-out examples, which are functionally identical) you have a pretty good example of an anti-pattern: you're directly mutating the nested properties of an object which is passed directly to Mithril's reconciliation algorithm doesn't traverse the nested trees of the properties of That being said, I think you have a pretty good candidate for a docs PR. I wouldn't mind seeing this explained in the anti-patterns sections of the vnodes page and the "m" api page, as well as in the final section of the autoredraw page. |
Beta Was this translation helpful? Give feedback.
-
We do need more information pertaining to anti-patterns. IIRC @barneycarroll has written at length about this (but I might be mistaken). The example @gjmcn gives here is actually something I've seen many folks come across over the years. |
Beta Was this translation helpful? Give feedback.
-
Mithril.js version: 2.2.2
Browser and OS: Chrome, Windows 10
The following had me confused for some time:
I think the issue is that the
// does not trigger redraw
versions are resuing an object withinattrs
and I guess this is not allowed? If so, the problem is that (unlike when reusingattrs
itself) Mithril does not give a warning for the above case. Perhaps it should? Or if this is too inefficient, maybe this could be covered more in the docs? - apologies if it is and I missed it!Beta Was this translation helpful? Give feedback.
All reactions