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

1624 questions
13
votes
2 answers

set array of data into mobx array show proxy objects

I'm using react js with mobx and I get data from api. the data I get is array of objects. when I set the data into mobx variable then I see array of proxy objects(not sure what the proxy says). I'm trying just to set the array of objects I get from…
Manspof
  • 2,132
  • 19
  • 61
  • 143
12
votes
3 answers

Correct way of Creating multiple stores with mobx and injecting it into to a Component - ReactJs

As suggested here in the Mobx documentation I have created multiple stores in the following manner: class bankAccountStore { constructor(rootStore){ this.rootStore = rootStore; } ... class authStore { constructor(rootStore){ …
uneet7
  • 2,012
  • 3
  • 17
  • 34
12
votes
2 answers

All table rows re-render after selection changes

I have table of customers and the selected customer is stored in the ViewState. The problem is that all rows re-render when the selection changes which is quite slow. Ideally only the selected row and the row previously selected would re-render, but…
jpfollenius
  • 15,826
  • 9
  • 83
  • 148
12
votes
4 answers

How to save Mobx state in sessionStorage

Trying to essentially accomplish this https://github.com/elgerlambert/redux-localstorage which is for Redux but do it for Mobx. And preferably would like to use sessionStorage. Is there an easy way to accomplish this with minimal boilerplate?
anthony-dandrea
  • 2,114
  • 3
  • 23
  • 38
12
votes
2 answers

Mobx: Observable array does not display correctly

I am trying to understand how to use observable array with Mobx. I have a hard time to figure out why this: let entities = observable([]); entities[0] = "foo"; autorun(() =>{ console.log(entities); }); writes: [$mobx: Object] 0: (...) 1: (...) 2:…
dagatsoin
  • 2,337
  • 5
  • 23
  • 48
12
votes
2 answers

Two ways of defining ES6 React Components

I was looking at this fiddle for MobX and I've seen these two ways of defining React Components in ES6 other places as well, like Dan Abramov's egghead redux video series. @observer class TodoListView extends Component { render() { …
Grant Eagon
  • 1,324
  • 1
  • 12
  • 23
11
votes
4 answers

MobX performance when replacing observable data

I need to replace data in my observable object when I get a new dump from the socket: class Store { @observable data = { foo: 'bar' } replaceFromDump(newData) { this.data = newData } } const store = new…
David Hellsing
  • 97,234
  • 40
  • 163
  • 203
11
votes
1 answer

using mobx with react functional components and without decorators

I'm trying to get MobX to work with functional components in react. I want to do this without having to use decorators. I have set up an app with create-react-app, added MobX and MobX-react as dependencies. However, I can't seem to get observables…
Marcus
  • 305
  • 1
  • 3
  • 11
11
votes
5 answers

React Native component opacity not updating when props updated

I have a React Native child component, which renders a button in a semi-transparent state if the disabled prop is set to true. The prop is likely to be updated after the app initially loads (once it has got its data), so will not be the initial…
Adamski
  • 3,307
  • 2
  • 29
  • 72
11
votes
1 answer

MobX Mutability vs Immutability

Why MobX encourage mutable objects in their docs?? But, I see a tutorial about MobX: http://orlandohamsho.com/javascript/mobx-react-tutorial-building-first-application/ And, he used immutable approach in his tutorial instead of mutable one (see…
Terry Djony
  • 1,584
  • 4
  • 18
  • 37
10
votes
1 answer

How to track nested object in a MobX store

Let's stay I have this myObject loaded via an API call: myObject = { fieldA: { details: 'OK', message: 'HELLO' }, fieldB: { details: 'NOT_OK', message: 'ERROR' }, } Only details and message of each field can change. I want this object to be…
jeanpaul62
  • 6,379
  • 6
  • 40
  • 74
10
votes
3 answers

React Mobx - component not updating after store change

Using Mobx, after updating the store (i.e. clicking the button) the component does not re-render. I've installed mobx devtools which shows nothing after the initial load, and there is no error in the console. Any ideas what I've done…
Chris
  • 1,355
  • 3
  • 16
  • 31
10
votes
5 answers

Using MobX observable decorators with create-react-app

The MobX docs tell me I must "use the transform plugin transform-decorators-legacy and make sure it is first in the plugins list", in order for the decorators to work. The MobX boilerplate project suggests I need a .babelrc like: { "presets": [ …
Scott
  • 3,541
  • 2
  • 13
  • 17
10
votes
5 answers

Mobx performance

I read from different sources that mobx outperforms react renderer and are faster then redux. However if I made couple of tests it shows that adding new data to mobx observables are pretty slow. In react-native environment every milliseconds counts…
Mac
  • 308
  • 1
  • 3
  • 10
9
votes
1 answer

Difference between mobx's `action.bound` and arrow functions on class functions?

Using arrow functions on a class with babel transpiles it so the definition is bound in the constructor. And so it is not in the prototype and it is not available via super when inheriting. It is also not as efficient when scaling by creating many…
bitten
  • 2,095
  • 2
  • 18
  • 39