mobx-state-tree is a state container for javascript apps that is powered by Mobx
Questions tagged [mobx-state-tree]
209 questions
0
votes
1 answer
Nested Models with separate API calls and separate stores (using custom references)
I'm wondering what's the best practice to do two separate fetches to data that would belong to the same Model. One to get all Users data and a separate one that would request their Traits and add them to each User.
I think I could create a reference…

emmaielle
- 314
- 3
- 12
0
votes
1 answer
Trying to create firebase user in MST(mobx state tree)action
I am trying to create new user in firebase using MST actions.
My code looks something like this:
.actions((self => ({
createUserWithEmailPassword:
flow(function*(password: string) {
console.log('creating user');
…

Freddy
- 2,216
- 3
- 31
- 34
0
votes
2 answers
Where to Put Code that should run First ReactJs + Mobx State Tree
I have some code that grabs the users ipAddres. I do this right now in my componentDidMount in my app.js
async componentDidMount() {
await eventTrackingStore.getIpAddress();
}
So I did it in my app.js as it is my root component and I only…

chobo2
- 83,322
- 195
- 530
- 832
0
votes
1 answer
Performing asynchronous actions with parameters mobx-state-tree
Using mobx-state-tree I want to pass in parameters to an asynchronous action. They recommend to use generator functions. Their examples does not supply examples using parameters, and I don't find it obvious how to.
I have tried wrapping the flow…
0
votes
2 answers
UI Flickers when I drag and drop and item
I have a problem getting react-beautiful-dnd to work without flickering. I have followed the example in the egghead course. Here is my code sample.
Item List Container
onDragEnd = (result) => {
if (this.droppedOutsideList(result) ||…

Chukwuma Zikora
- 109
- 1
- 4
- 10
0
votes
2 answers
Stop Axios Requests On Route Change with Mobx State Tree?
I am using axios and I noticed that say someone goes to Route A and then Quickly clicks on a button to Route B the Route A requests will still be running and weird results can happen.
I am doing something like this
getAllTaxRates: flow(function*()…

chobo2
- 83,322
- 195
- 530
- 832
0
votes
0 answers
Upgrading to mobx-react@6.0.0 causes an infinite loop
I've just upgraded from mobx-react@5.4.4 to version 6.0.0 and my app broke totally. Instead of starting, it consumed more and more memory until it crashed. What I'm looking for is an advice on how to best approach it... neither the stack trace nor…

maaartinus
- 44,714
- 32
- 161
- 320
0
votes
1 answer
mobx-state-tree does not update the model with react-native
I try to create a User model with react-native, mobx, mobx-state-tree
My User Model:
const UserProfileModel = types.model("UserProfile").props({
description: types.maybeNull(types.string),
})
/**
* Model description here for TypeScript hints.
…

loic.lopez
- 2,013
- 2
- 21
- 42
0
votes
1 answer
How to get model/state to listen after a change is made in Mobx state tree?
I have two models/stores each referring to an object. Store2 gets populated after Store1 gets populated and receives a childId. How would I have Store2 listen to when Store1 gets populated?
Store1
import {action} from 'mobx'
import axios from…

KamSami
- 387
- 1
- 4
- 14
0
votes
1 answer
React-Native MobX-State-Tree store unavailable on registerComponent
Given the following setup:
import { AppRegistry } from "react-native";
import { Provider } from "mobx-react";
import Application from "./src/components/Application";
import ApplicationStore from "./src/stores/ApplicationStore";
import { name as…

studiobrain
- 1,135
- 2
- 13
- 35
0
votes
1 answer
Mobx store function call in another Observer component
I have a Mobx Store and i am passing this store inside the Provider and when i am consoling this.props its showing the structure of Mobx store.
Below is my Mobx Store
import { observable, computed, action, useStrict, runInAction, toJS } from…

abankitbaid
- 137
- 5
- 15
0
votes
1 answer
mobx-state-tree convert optional type to non-optional
How to convert optional type to non-optional
from types.optional(types.string) to types.optional
As far as I know this works:
const t = optional(types.string);
delete t.defaultValue
But this seems very wrong. Is there a better way?

Eduard Jacko
- 1,974
- 1
- 16
- 29
0
votes
1 answer
Mobx State Tree: Create instance on the fly
I have a model named Event, which has a property referencing to another model.
I create the Event instances on the fly, without connecting them to a root store.
The problem is that mst cannot resolve the reference (I guess because they are not on…

Eyal Cohen
- 1,188
- 2
- 15
- 27
0
votes
1 answer
How to call an mobx-state-tree action if a computed view changes?
Basically what I'm trying to do is to call an action if a computed view changes.
const Store = types
.views(self => ({
get computedValue() {
return somethingComputed;
}
}))
.actions(self => ({
doSomething() {
…

Leandro Oriente
- 103
- 6
0
votes
1 answer
react mobx, component does not render new observable
I am using Mobx with React (typescript) to get some data from firebase and display it. at the first render no data is rendered on the screen till I change for instance tabs in view that the component get re-rendered.
the component class:
interface…

Amir-Mousavi
- 4,273
- 12
- 70
- 123