Questions tagged [mobx]

Functional reactive programming library in JavaScript.

About

MobX is a battle tested library that makes state management simple and scalable by transparently applying functional reactive programming. The philosophy behind MobX is very simple:

Anything that can be derived from the application state, should be derived. Automatically.

which includes the UI, data serialization, server communication, etc.

Links

1876 questions
6
votes
3 answers

mobx react action binding

For those who has written apps with mobx + react, I'm wondering if there's a better way to handle context issue (eg. this. returns undefined in mobx store) when using onClick event handler inside a react component w/ inject & observer. I have been…
Bi Yoo
  • 249
  • 4
  • 9
6
votes
1 answer

Support for the experimental syntax 'decorators-legacy' isn't currently enabled

I am getting the above error when I am using mobx-react and while trying to use annotations.Here I am using .js and not .ts. All the solutions provided earlier not successful for me. import React, { Component } from 'react'; import { withRouter,…
6
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
  • 952
  • 1
  • 11
  • 26
6
votes
1 answer

React-Mobx Warning: A component is changing an uncontrolled input

I use React + TypeScript + Mobx. I made the form with input, everything is working, but the browser gives an error. What am I doing wrong? Warning: A component is changing an uncontrolled input of type text to be controlled. Input elements should…
cooperJCW
  • 65
  • 4
6
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
  • 133
  • 1
  • 5
6
votes
2 answers

Accessing MobX store in vanilla ES6 Javascript class

This one is piece of cake in React. If you want your MobX store to be available in any React component, you just use mobx-react @inject component. Something like: import React from 'react'; import {inject} from…
Ignacio Segura
  • 678
  • 8
  • 15
6
votes
4 answers

Mobx @computed functions with parameters

I'm new to Mobx but so far it's been working great and I've managed to get pretty far. I have a react-native application with mobx, and mobx-persist. I'm using axios to pull posts from a Wordpress site. The functionality that I'm trying to improve…
6
votes
2 answers

ReactJS .default is not a constructor

I'm new to React and Mobx so I try to do a small app. When I try to run it i get the error: Uncaught TypeError: _releasesState2.default is not a constructor. I'm about to bash my head in since I have no clue what the issue is. Here is what I got so…
ST80
  • 3,565
  • 16
  • 64
  • 124
6
votes
1 answer

React/Mobx - component is re-rendering, but componentWillReceiveProps() is not being called

I have React/Mobx app. When I am making changes in the store, the component is updating (re-rendering), but I need to make some comparisons for adding some more functionality, so I want to use componentWillReceiveProps(nextProps) and compare…
Hayk Aghabekyan
  • 1,087
  • 10
  • 19
6
votes
2 answers

How to convert single screen app to tab based app using react-native-navigation?

I am trying my hands on react-native-navigation but I am stuck with a simple problem. The app has a login page which doesn’t have tabs. (very much similar to facebook login page)(Image ref - The image is just to give an idea. Image Courtesy - …
6
votes
2 answers

How to check if object is in Mobx observable array?

I'm using indexOf in a React component to style a button based on whether an object is in an mobx observable array. The button is for favoriting. It pushes the object for that specific list item into an observable array in the store called…
Kyle Pennell
  • 5,747
  • 4
  • 52
  • 75
6
votes
1 answer

Mobx returning ObservableObjectAdministration instead of my object

I'm new to mobx. I was wondering why I'm getting ObservableObjectAdministration when I call the computed getServerUrls() function instead of the object. Below is my store. import { observable, computed } from 'mobx'; import { ServerNames } from…
devwannabe
  • 3,160
  • 8
  • 42
  • 79
6
votes
2 answers

mobx - Leading decorators must be attached to a class declaration

I want to use the MobX decorators, but when I try to run my code, I get the following error message: Leading decorators must be attached to a class declaration My application is storing data in Datastores from nedb and I want to observe them with…
grahan
  • 2,148
  • 5
  • 29
  • 43
6
votes
1 answer

Mobx: add new (array) property to observable object

I have an observable object, where I want to store some data. Keys are unique IDs for my customer entity, and values are arrays of customers' orders (which are objects themselves). I initialize an object with: @observable data = {}; Then, when I…
Matúš Čongrády
  • 1,340
  • 3
  • 17
  • 29
6
votes
1 answer

Why MobX is less suitable for applications that have an append only domain model?

The creator of MobX, Michel Westrate, said: MobX is suitable for building any app that needs to perform CRUD like operations on the state model. It is less suitable for applications that have an append only domain model. If I understood…
Yaron Levi
  • 12,535
  • 16
  • 69
  • 118