Is storing JSX.Elements in an observable supported? #3418
-
ExampleObservable data storing a JSX element
React component using observable data
Is this supported? Good idea, bad idea? Any suggestions welcome |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Maybe portals are a better solution here: https://stackoverflow.com/questions/61113318/is-it-a-misuse-of-context-to-use-it-to-store-jsx-components-for-display-elsewher ? Maybe both are fine |
Beta Was this translation helpful? Give feedback.
-
You can store a reference to an element, but you should treat the element itself as immutable and mark the field as It's usually better to store react's Don't call it |
Beta Was this translation helpful? Give feedback.
You can store a reference to an element, but you should treat the element itself as immutable and mark the field as
observable.ref
.It's usually better to store react's
ref
object instead of the element directly. Otherwise make sure to pass a callback toref={el => store.el = el}
.Don't call it
component
. Component is a function/class, element is an object.