which type of comparer does mobx use ? #3751
Unanswered
prashantkn94
asked this question in
Q&A
Replies: 2 comments 3 replies
-
reference equality, which is in 98% of the cases the right choice. Not 100%
sure whether that is `===` or `Object.is` from top of my head
…On Thu, Aug 31, 2023 at 8:03 PM prashantkn94 ***@***.***> wrote:
I see there are different type of comparers in
packages/mobx/src/utils/comparer.ts . But which type of comparison is
actually done on the observables value before deciding whether to
re-trigger component for React.
Also, what comparer is used for reactivity in general ?
—
Reply to this email directly, view it on GitHub
<#3751>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN4NBBM3SSFDXA6U5MGKBDXYDGYLANCNFSM6AAAAAA4GOH6YY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
3 replies
-
MobX traps read and writes to all properties of observable objects, so if
you read obj.name in observer, it will be detected and matched against
future mutations of that property. See
https://mobx.js.org/understanding-reactivity.html#understanding-reactivity
or the original blog post:
https://www.mendix.com/blog/making-react-reactive-pursuit-high-performing-easily-maintainable-react-apps/
…On Fri, Sep 1, 2023 at 4:31 PM prashantkn94 ***@***.***> wrote:
I have read the docs on reactivity. Let's say we have an observable object
like below
@observable obj = { name: 'first', lastName": 'last' };
and we update it like below:
obj.name = "myName"
Now the reference of the obj is still the same but mobx will re-trigger
the render. Please explain
—
Reply to this email directly, view it on GitHub
<#3751 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN4NBEBGHISABRERKNZ4TTXYHWSLANCNFSM6AAAAAA4GOH6YY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I see there are different type of comparers in packages/mobx/src/utils/comparer.ts . But which type of comparison is actually done on the observables value before deciding whether to re-trigger render for React component.
Also, what comparer is used for reactivity in general ?
Beta Was this translation helpful? Give feedback.
All reactions