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
Rendering a TemplateResult stored in a MobX store does not work #4565
Comments
Fix
More Info MobX is making the I'm not very familiar with MobX so there may be other fixes, but by default Also, you may wan to consider using lit-mobx which provides a set of tools for integrating mobx and lit. |
The downside of those workarounds is that they either affect all other values in the store (breaking something else) or require configuration per property in the store. In this demo case it is just |
Proxies break all kinds of maps, this isn't unusual to lit-html. Unless you're the only owner of a reference to the object, via the proxy, then you will have two objects - the original and the proxy - going around your app that act as different keys in maps and sets and are different for referential equality. I'm not sure if the MobX advice on turning an observable into a plain object will work: https://mobx.js.org/observable-state.html#converting-observables-back-to-vanilla-javascript-collections Even if it did, that would be cumbersome to remember to do. The best bet is to not make template results observable. They're immutable anyway. |
Which package(s) are affected?
Lit Core (lit / lit-html / lit-element / reactive-element)
Description
It would be expected that this snippet
Would render
hello
to the document body, in the same way asbut instead it fails with
Reproduction
As above
Workaround
Not sure what a sensible workaround would be. Excluding only the template that is somewhere deep inside a mobx object does not seem feasible
Is this a regression?
No or unsure. This never worked, or I haven't tried before.
Affected versions
lit-html 3.1.2
Browser/OS/Node environment
Chrome 121.0.6167.160
The text was updated successfully, but these errors were encountered: