Skip to content

Can array be both ref observable and deep observable at the same time? #3262

Answered by mweststrate
Lechros asked this question in Q&A
Discussion options

You must be logged in to vote

To add some more context, please check out https://mobx.js.org/understanding-reactivity.html, what changes reactions depend on doesn't depend on what is observable (that is just the prerequisite), but on what is read. So if one reaction deeply reads the data, and the other one only shallowly the array, one will respond to deep changes and the other one to array changes only. There is nothing special that needs to be done to achieve that.

When you do read some data in a reaction, but still don't want to react to them in the future, then untracked comes into play as suggested by @urugator, but these cases are in practice pretty rare.

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@Lechros
Comment options

@urugator
Comment options

@Lechros
Comment options

Answer selected by Lechros
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants