Questions tagged [mobx-state-tree]

mobx-state-tree is a state container for javascript apps that is powered by Mobx

172 questions
15
votes
5 answers

MobX vs. MobX State Tree

Why should I use MobX State Tree over vanilla MobX? It seems like any time I read about MobX, MST is mentioned in the same place. Is anyone actually using just MobX by itself? Probably too general of a question...
John
  • 555
  • 8
  • 16
14
votes
3 answers

Mobx-State-Tree - Assign to Array Type

I have this basic model. const stuff = types.model({ term: types.string, excludeTerm: types.string, stores: types.array(types.string) }).actions(self => ({ setTerm(term: string) { self.term = term }, setExcludeTerm(term: string) { …
etudor
  • 823
  • 9
  • 17
14
votes
3 answers

How to get code completion for typed react component properties?

I am using react and mobx-state-tree and I use @inject to inject the stores into my component. So in the end I access the store via this.props.uiStore inside of my component. Unfortunately Visual Studio Code can't infer the type of my store, so I…
stoefln
  • 13,576
  • 16
  • 74
  • 131
9
votes
1 answer

Extending a model in mobx state tree

I have a bunch of stores each containing a list of one entity type like const userStore = EntityStore.create(....) const supplierStore = EntityStore.create(....) Some stores can offer additional functionalities, so I wrote const orderStore =…
maaartinus
  • 40,991
  • 25
  • 130
  • 292
7
votes
2 answers

Error: [mobx-state-tree] Failed to resolve reference XXX to type 'User'

Context I have a React application that is backed by mobx-state-tree (MST). One of the pages makes two parallel API calls to fetch a list of Projects and a list of system Users. The responses of these two APIs are then applied as snapshot to two…
Igor Soloydenko
  • 7,161
  • 7
  • 39
  • 73
5
votes
2 answers

Mobx State Tree reference type and Typescript

I'm using mobx-state-tree with Typescript in a React application. And, I'm having an issue with Typescript where it complains about the type of the mobx type types.safeReference. It looks like the type of safeReference in the model definition is…
ataravati
  • 8,159
  • 5
  • 47
  • 70
5
votes
2 answers

How to have a nullable string value in Mobx-State-Tree

I'm trying to create a model with a optional, nullable string value. I've tried using both hint: types.optional(types.string, ""), and hint: types.maybe(types.string), Both results in error when I try to set a json object as to the…
AbsoluteSith
  • 1,727
  • 19
  • 45
4
votes
1 answer

How to make jsDoc "import" work with vscode?

I want to import a node module with @import, but it seems visual studio code is not getting it. Or am I doing it wrong?
stoefln
  • 13,576
  • 16
  • 74
  • 131
4
votes
1 answer

How to describe model of mobx-state-tree with interface of typescript?

I have some interfaces already, and I want to describe models with this interfaces, just like the code below. Otherwise I have to write again by using types of mobx-state-tree. But this is not the right way, what is the valid solution ? import…
马邦德
  • 83
  • 1
  • 8
4
votes
1 answer

How to Persist Mobx State Tree in React Native?

I need to persist a MST Store in React Native. The data is changed seldomly. I'm confused between using AsyncStorage and AutoRun.
Aswin Mohan
  • 630
  • 1
  • 8
  • 20
4
votes
1 answer

How to Change Parent State from Child - Mobx State Tree?

I am trying to make a Nav in reactjs with Mobx State Tree. Right now I have skinny vertical Nav bar with a list of icons. Now what I want to do is add sub menu items to certain ones. When these ones are clicked the Nav goes from skinny to wide(ie…
chobo2
  • 75,304
  • 170
  • 472
  • 780
4
votes
1 answer

mobx-state-tree: How to clone a model that includes references?

I'm trying to clone a model that references another model, but I get: Error: [mobx-state-tree] Failed to resolve reference 'H1qH2j20z' to type 'AnonymousModel' (from node: /usualCustomer)... in the clone. The original resolves okay. Here are my…
user2736142
  • 113
  • 1
  • 5
4
votes
3 answers

Ensuring interface compliance in MobX State tree models

I have interfaces defined for my typescript server APIs and when defining models through MobX state tree I would like to ensure that the typescript compiler enforces that the model snapshots comply with these interfaces. So if an additional…
lorefnon
  • 12,112
  • 4
  • 54
  • 87
3
votes
3 answers

Support for the experimental syntax 'decorators-legacy' isn't currently enabled How To Enable In Create React App?

I am trying to get up and running with react create app and mobx state tree. I keep getting Support for the experimental syntax 'decorators-legacy' isn't currently enabled (4:1): I never used react create app so I am not sure how to enable, I…
chobo2
  • 75,304
  • 170
  • 472
  • 780
3
votes
2 answers

How to deal with inconsistent mobx-state-tree snapshots?

I am writing an electron app and I keep all my app data inside a single MST tree. Now I noticed that every now and then you run into a situation where data becomes inconsistent (missing reference object etc). While this can happen with any type of…
stoefln
  • 13,576
  • 16
  • 74
  • 131
1
2 3
11 12