Accessing Referenced Data #287
Replies: 1 comment 3 replies
-
Hi there, reference access are made explicit on purpose (kind of like useRef in react), this is, so the user has a clear notion that he's using a reference with all its pros an cons (e.g., that it will be valid only as long as the source (referenced node) is still there, etc). For example, due to the accessor magic, in the case of MST, if you want to know if a reference is still valid you need to do a weird construct like:
because in the case the original selectedTodo no longer exists, then just doing in mobx-keystone you can do |
Beta Was this translation helpful? Give feedback.
-
Hi There,
I'm looking at
mobx-keystone
andmobx-state-tree
as options for a normalized global store for a react app.In
mobx-state-tree
they give an example here where a normalized reference can be accessed in a denormalized manner:With
mobx-keystone
I noticed that using acustomRef
you accessed the referenced item via the.current
property of the ref. So as I understand it, if I build something similar to the above example withmobx-keystone
to get the equivalent output I would instead have:However is there a way to access it the same way was you would in MST (accessing it and letting
mobx-keystone
do some magic and replace the reference with the actual object)?Beta Was this translation helpful? Give feedback.
All reactions