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
0
votes
1 answer

Get item from MobX store which is observable object?

I am creating a simple React single page app, that is pulling info from Behance API, and showing it on the site. I am using MobX to store portfolio items, as well as modules a from a single item. The store.js looks like: import { observable } from…
dingo_d
  • 9,839
  • 10
  • 62
  • 102
0
votes
1 answer

Mobx4 - observable.map .keys() .values() return function instead of array

I am trying to declare an observable.map using the decorate syntax. class UiStore { loaders = observable.map({}) } export default decorate(UiStore, { loaders: observable }) But when I try to use loaders.keys() it just outputs the function…
Miha Šušteršič
  • 8,483
  • 17
  • 69
  • 133
0
votes
1 answer

Mobx4 - declaring observable in store throwing a sintax error

According to the migration guide from mobx, this is the correct way to assign observables now (the ... stand for other, irrelevant code): class BaseMapsStore { uiStore = null mapStore = null datesStore = null selectedBaseMap = "OSM" …
Miha Šušteršič
  • 8,483
  • 17
  • 69
  • 133
0
votes
1 answer

MobX not rerendering React component as used @computed is changed

MobX appears to not be working for me. I have essentially these two files: @inject("apiDepo") @observer class Test extends React.Component { public render() { return
{this.props.apiDepo.remoteNum}
} } . // apiDepo.ts class…
Seph Reed
  • 4,704
  • 7
  • 30
  • 65
0
votes
0 answers

Typescript with ReactJs and MobX getting error

all I am getting error while running command like npm start and also installed all packages using npm install but not working. I am sharing my screenshot:
Akram Khan
  • 114
  • 8
0
votes
1 answer

computed fromPromise with nested promises does not reevaluate when observable changes?

I'm running into this issue where I have certain computed values that are promises of promises, filtered on observables, which are not reevaluated when the observables it depends on changes. Here's an example, class CustomerStore { @observable…
agadzik
  • 41
  • 1
  • 7
0
votes
1 answer

How should I implement lazy behaviour with MobX?

The following code is intended to print a reversed list of users as soon as a new user is added, but it doesn't work. The autorun is listening to a lazy calculated var (_userArrayRev), but how to enable the recalculation of that var? The autorun is…
cdarwin
  • 3,801
  • 8
  • 38
  • 56
0
votes
1 answer

MobX and hashmap update not triggering autorun

I'm trying to update the _users hashmap of class Test, and two "strange" things are happening (I'm a MobX newbie): MobX, even if strict mode is enabled, allows me to update _users even though it is observable and addUser() is not an @action The…
cdarwin
  • 3,801
  • 8
  • 38
  • 56
0
votes
2 answers

React+Javascript:-Component will update is getting called too many times causing my application to crash

componentWillUpdate() { //Axios GET method for getting all the trades //Adding data of db into mobx store/or syncing data of db and store axios.get(`http://localhost:8091/trade`) .then(res => { this.props.store.arr =…
AConsumer
  • 1,414
  • 1
  • 10
  • 24
0
votes
1 answer

There are multiple mobx instances actives

Since the last update of Mobx 3.6 to Mobx 4, my application just stopped working. I'm using react-native and I just followed the instructions to migrate to the newest features, but my application just keeps crashing displaying the following…
Lucas Dias
  • 86
  • 1
  • 9
0
votes
2 answers

Issue with mobx-react-forms

I am trying to get started with mobx-react-forms but am running into an error: Unhandled Rejection (Error): Validation Error: Invalid Field Instance -> const form = new Form(); Here is my code: import React, { Component } from 'react'; import {…
Shawn Northrop
  • 5,024
  • 6
  • 35
  • 70
0
votes
1 answer

Passing JSX elements to a function requires manual keys to be present?

I'm trying to pass a React JSX element to a function, so that this element can be displayed as part of a React component, like in the following example: import React from 'react' import { render } from 'react-dom' import { action, observable } from…
hyperknot
  • 12,019
  • 22
  • 87
  • 143
0
votes
1 answer

MobX 4 `decorate` doesnt work with `computed`

EDIT: this is now solved and i no longer need help. see solution below. thank you I am getting a weird error when trying the new decorate syntax with computed variables - any idea why it might sometimes invalidate the store? I'm pretty sure the…
swyx
  • 1,745
  • 3
  • 18
  • 31
0
votes
1 answer

Mobx(4.0.1) and mobx-state-tree(1.3.1) not compatible

OS - Windows 10 x64 NodeJs v8.9.3 npm 5.7.1 repository for sample code - https://github.com/niral3737/testMobxStateTreeApp I am working with mobx-state-tree and I have created a model Invoice with a field name. I am using that model in App.js…
Niral Patel
  • 62
  • 1
  • 7
0
votes
1 answer

webpack-dev-server doesn't compile React components in subfolders

I'm developing React + Mobx application using webpack-dev-server. Project folders structure: /assets /dist /public /src /components /common Field.jsx Button.jsx ... ComponentA.jsx ComponentB.jxs ... /stores …
Vlad Morzhanov
  • 992
  • 1
  • 9
  • 26