Questions tagged [mobx-state-tree]

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

172 questions
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
  • 895
  • 2
  • 9
  • 30
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
  • 95
  • 1
  • 11
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,277
  • 9
  • 22
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
  • 993
  • 2
  • 12
  • 23
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() { …
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
  • 3,249
  • 4
  • 40
  • 86
0
votes
1 answer

MobX State Tree generator does not allow modified state in a successful promise?

Via the code following I get this error: error: Error: [mobx-state-tree] Cannot modify 'AuthenticationStore@', the object is protected and can only be modified by using an action. the code (generator) in…
studiobrain
  • 895
  • 2
  • 9
  • 30
0
votes
0 answers

Injecting MobX State Tree store into react components throwing error

Issue: I am getting an error when attempting to inject a MST store into react class component: Error: Uncaught [Error: MobX injector: Store 'auth' is not available! Make sure it is provided by some Provider the error stems from the LoginForm…
studiobrain
  • 895
  • 2
  • 9
  • 30
0
votes
1 answer

Mobx-state-tree create form with types.identifier field on model

I've started using mobx-state-tree recently and I have a practical question. I have a model that has a types.identifier field, this is the database id of the resource and when I query for existing stuff it gets populated. When I am creating a new…
Donato Azevedo
  • 1,189
  • 1
  • 11
  • 21
0
votes
1 answer

Mobx state tree getting started part 2

Does anyone know if there's a second part of the getting started available? I can see there is an annotation about the second part but actually there is no link nor any further information about it. At least I can't find it. Anyone knows? Next up …
Mugetsu
  • 1,051
  • 2
  • 12
  • 24
0
votes
1 answer

Mobx state tree nested stores injection

I have one issue using mobx-state-tree. If we have nested stores with following structure login(store):{ //some primitives }, mainPage(store):{ slider:(store):{ //some primitives }, userList:(store):{ //some…
0
votes
1 answer

AXIOS Async/Await How to best write the code?

I am writing my first ajax call using Axios, Mobx/Mobx State Tree (MST) and Reactjs. In MST they have something called flows what basically does the same thing as async/await getCustomers: flow(function * (){ const response = yield…
chobo2
  • 75,304
  • 170
  • 472
  • 780
0
votes
1 answer

mobx-state-tree literal array

is it possible to create literal array type in MST? It should be an equivalent to type Interval = ['1min', '5min']; here is an example of code which throw an error type Interval = '1min' | '5min'; export interface AppStore { config: { …
Eduard Jacko
  • 1,277
  • 9
  • 22
0
votes
1 answer

Single Object in Mbox State tree?

If I made a store(RegistrationStore) and there is only 1 company created what type do I use? .model("RegistrationStore", { company: types.optional(????) })
chobo2
  • 75,304
  • 170
  • 472
  • 780
0
votes
1 answer

Computed views as functions without arguments instead of getters

If I re-write the example in the Views section of the MST's README file, but using a normal function without arguments instead of a getter, will it still be treated as a computed value with same benefits as using a getter? const UserStore = types …
MikO
  • 16,652
  • 11
  • 69
  • 103
1 2 3
11
12