-
Have been playing around a little with the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Generally speaking if it wouldn't change the output it's not relevant, eg: // Conditions
observer(({ store }) => {
return store.cond ? store.a : store.b
// if `store.cond` is `true`, `store.b++` is NOT relevant
})
// Object props
observer(({ store }) => {
return store.a;
// `store.b++` is NOT relevant
// `store.a++` IS relevant
})
// Passthrough
observer(({ store }) => {
return <User user={store.users[0]}/>
// `store.users[0].name = "new name"` is NOT relevant for this component
// it can be relevant for User component, so it may need to be observer
// `store.users = [{ name: "foo" }]` IS relevant
// `store.users[0] = { name: "foo" }` IS relevant
}) Note in all above cases, swapping The logic is simple: if value was accessed, it will affect the result, therefore is relevant (assumes there are no unused vars or meaningless expressions). |
Beta Was this translation helpful? Give feedback.
Generally speaking if it wouldn't change the output it's not relevant, eg:
Note in all…