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
... you won't get proper IDE introspection, navigation and refactoring support. For example, if you Cmd+Click on action1() to see where it is referenced, IntelliJ jumps here:
NOTE: the last approach will incur runtime performance penalty as accessing such computed values (e.g. inside render() method of an observed component) always leads to full recompute (see this issue for details). For a heavily used computed properties it's recommended to use one of above approaches.
I guess this only refers to views, but should be OK for actions and volatile.
The text was updated successfully, but these errors were encountered:
(Creating this issue as a follow-up of this conversion in the mst-gql repo: mobxjs/mst-gql#445 (comment))
Another issue that may worth mentioning or explaining more in the docs.
If you declare the actions like this (version 1):
... you won't get proper IDE introspection, navigation and refactoring support. For example, if you Cmd+Click on
action1()
to see where it is referenced, IntelliJ jumps here:node_modules/mobx-state-tree/dist/types/complex-types/model.d.ts
You can also use this (version 2):
This is the worst: Cmd+Click jumps in to the
return{}
and if you Cmd+Click insidereturn{}
it jumps to the function definition no the usages.And finally, you can assign the actions to a named variable, which you return (version 3):
In this case Cmd+Click on
actions1()
will correctly list or jump to its usages and can refactor.This is a huge difference in DX!.
Version 1 and 2 are the default suggestions in the docs now: https://mobx-state-tree.js.org/concepts/actions
Version 3 is mentioned as a tip: https://mobx-state-tree.js.org/tips/typescript, however, it comes with a note in bold:
I guess this only refers to views, but should be OK for actions and volatile.
The text was updated successfully, but these errors were encountered: