Questions tagged [mobx-react]

MobX is a battle-tested library that makes state management simple and scalable

React and MobX together are a powerful combination. React renders the application state by providing mechanisms to translate it into a tree of renderable components. MobX provides the mechanism to store and update the application state that React then uses.

Both React and MobX provide optimal and unique solutions to common problems in application development. React provides mechanisms to optimally render UI by using a virtual DOM that reduces the number of costly DOM mutations. MobX provides mechanisms to optimally synchronize application state with your React components by using a reactive virtual dependency state graph that is only updated when strictly needed and is never stale.

746 questions
6
votes
1 answer

How to use mobx-react 'observer' without decorator syntax?

I am trying to shoe horn mobx into a vr application I am making with react 360. I've tried to use the decorator syntax but after wasting a solid chunk of time trying to implement it, I've decided to use the nondecorator syntax. Here is an example…
Dan Rubio
  • 3,965
  • 5
  • 34
  • 74
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
3 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
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,057
  • 10
  • 18
6
votes
5 answers

Mock Ajax (Reactjs + Mobx)

I want to make some fake my ajax calls so when on localhost I can bring back dummy data from a fake method instead of doing real calls to my server(where the structure might not exist). What is the best way to do this in reactjs + mobx? I was…
chobo2
  • 75,304
  • 170
  • 472
  • 780
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
  • 4,306
  • 3
  • 38
  • 65
6
votes
1 answer

How to get a plain object from mobx object?

I defined a mobx map as below: @observable editors = observable.map(); then I added object on the editors as below: editors.set(key, { alias: 'alias-1', message: 'hello', }) when I get the object from editor as below: let myEditor =…
Joey Yi Zhao
  • 23,254
  • 37
  • 138
  • 276
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
  • 2,746
  • 5
  • 34
  • 67
6
votes
2 answers

Detect when mobx observable has changed

Is it possible to detect when an observable changes in any way? For instance, say you have this: @observable myObject = [{id: 1, name: 'apples'}, {id: 2, name: 'banana' }] And later on, with some user input, the values change. How can I detect this…
capvidel
  • 319
  • 2
  • 11
5
votes
2 answers

Mobx State Tree reference type and Typescript

I'm using mobx-state-tree with Typescript in a React application. And, I'm having an issue with Typescript where it complains about the type of the mobx type types.safeReference. It looks like the type of safeReference in the model definition is…
ataravati
  • 8,159
  • 5
  • 47
  • 70
5
votes
1 answer

Shouldn't useContext() only be used for low frequent updates? (mobx-react-lite)

Almost all examples (even the official documentation) use mobx-react-light in combination with useContext() hook. However, React, many articles and blog-posts advice to NOT USE useContext() for middle/high frequent updates. Isn't state something…
mleister
  • 443
  • 8
  • 23
5
votes
1 answer

Unable to expand and close collapsable on click

I have been on this for a little while and here is whats going on. I have an array in mobx Storage that I Would like to display in a collapsable view within a Flatlist in my React native component. The problem here is that when I click on it it does…
5
votes
0 answers

Is there a problem when use of mobx in my project , the error is 'Support for the experimental syntax 'decorators-legacy' isn't currently enabled'

I configured my package.json and babelrc but I got some errors when I used decorators. I use "react16.8.1" and "mobx5.9.4". My babelrc code: "presets": [ "@babel/preset-env", "@babel/preset-react", ], "plugins": [ …
5
votes
2 answers

Why useEffect doesn't fire on every render?

My component has two Rect.useEffect hook const Example = ({ user }) => { React.useEffect(() => { autorun(() => { console.log("inside autorun", user.count); }); }); // Only runs once React.useEffect(() => { console.log("Why…
Andrew-Dufresne
  • 5,014
  • 7
  • 41
  • 64
1 2
3
49 50