You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, accessing such computed values (e.g. inside render method of an observed component) always leads to full recompute. This is easily prooved by tracing those properties.
Tracer says:
[mobx.trace] 'PROP NAME' is being read outside a reactive context. Doing a full recompute
Which is true, because 'views' object itself is not observed, but properties are copied to 'self' during instance initialization.
This leads to performance drop as every such property is recomputed on every re-render.
Should we add a warning to the documentation or completely remove it in favor of
const Example = types
.model({
prop: types.string
})
.views(_self => {
const self = _self as IExample;
return {
get upperProp(): string {
return self.prop.toUpperCase();
},
get twiceUpperProp(): string {
return self.upperProp + self.upperProp;
}
};
});
type ExampleType = typeof Example.Type;
interface IExample extends ExampleType {}
The text was updated successfully, but these errors were encountered:
I think both. If it get's too long maybe put it in a separate md file in
docs. (the whole TS section). Thanks in advance!
Op ma 18 jun. 2018 om 17:13 schreef Gleb <[email protected]>:
In the documentation:
https://github.com/mobxjs/mobx-state-tree/tree/v2.0.5#typing-self-in-actions-and-views
it's said that one can use local "views" variable to refer a prop:
However, accessing such computed values (e.g. inside render method of an observed component) always leads to full recompute. This is easily prooved by tracing those properties.
Tracer says:
Which is true, because 'views' object itself is not observed, but properties are copied to 'self' during instance initialization.
This leads to performance drop as every such property is recomputed on every re-render.
Should we add a warning to the documentation or completely remove it in favor of
The text was updated successfully, but these errors were encountered: