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.

850 questions
3
votes
1 answer

component doesn't re-render when store udates mobx

I made a store, with one field and one action. However, when the event that triggers the action is triggered, the storage itself is not updated, and the component is not re-rendered. store: configure({ isolateGlobalState: true }); class CallStore…
3
votes
1 answer

mobx-state-tree error while converting to anonymousModel

What should happen - succesfully create RootStore from defaultSnapshot and reset it when needed, successful backcuping in localStorage. What happens - getting an error while trying to apply a snapshot, when attempting to open page, just by running…
bpalij
  • 301
  • 4
  • 9
3
votes
2 answers

Use Mobx Store's value in React Class Component?

I want to access a Hook in a React Class Component. Konva.tsx import * as React from "react"; import { Stage, Layer } from "react-konva"; import { useFrameItStore } from "../store/index"; import { BrowserWindow, SiteImage, TrafficSignal, URLBar }…
deadcoder0904
  • 7,232
  • 12
  • 66
  • 163
3
votes
1 answer

Mobx-react console warning related observer

Im getting below warning when I tried to run my react code, I have run 'npm run eject' and update package.js for making decorator work in react, it is working fine but Im getting below warning in console [MobX] You haven't configured observer…
Anudeep GI
  • 931
  • 3
  • 14
  • 45
3
votes
1 answer

MobX with React best practice with observer

I'm not really facing an issue, it's more like I'm wondering what is the best way I should use mobx with react. So here's my situation: I'am fairly new to mobx but I've got years of experience using react (mostly with redux). My new project is using…
3
votes
0 answers

Hot reloading with Mobx React decorators

As stated in MobX FAQ, Is React Native supported? Yes, mobx and mobx-react will work on React Native. The latter through importing "mobx-react/native". The devtools don't support React Native. Note that if you indend to use your observer components…
Estus Flask
  • 206,104
  • 70
  • 425
  • 565
3
votes
0 answers

How do you perform deep array updates with mobx?

I have one observable array in my store that is deeply nested. Lets called the property people (which contains elements of class Person). Now the Person class has a property products which is an array of Product, a class which also has nesting…
Jason Blade
  • 373
  • 2
  • 4
  • 17
3
votes
2 answers

Why isn't the mobx @computed value?

Simple: the computed value isn't updating when the observable it references changes. import {observable,computed,action} from 'mobx'; export default class anObject { // THESE WRITTEN CHARACTERISTICS ARE MANDATORY @observable attributes =…
ali_wetrill
  • 173
  • 1
  • 9
3
votes
2 answers

MobX: Avoid triggering re-render when object keys are not used in views

I have a list of observable objects: [ { key1: "x", updateTs: "y" }, ... ] The user can mutate these objects through the UI. Those changes are sent to a remote server, and once the request returns the "updateTs" is…
zino
  • 1,222
  • 2
  • 17
  • 47
3
votes
2 answers

Mobx @observable is not work if its init value is undefined in react-native 0.59

I'm migrating react-native 0.51.1 to 0.59.8. And I'm facing a problem of Mobx. If an @observable decorated member have assigned init value like this @observable cnt = 0; then it works. But if it's undefined, @observable cnt; then it doesn't…
Metalliza
  • 139
  • 1
  • 7
3
votes
1 answer

Create a new MobX store instance for a React function component

When using MobX with React you can create a new Store instance on a class component instance like so: const { extendObservable } = mobx; const { Observer } = mobxReact; class Store { constructor() { console.log("Created a store"); …
Tholle
  • 108,070
  • 19
  • 198
  • 189
3
votes
2 answers

Javascript ES5/ES6 classes and error handling

Say I have a class like this class SomeUIComponentDataStore { async function getUser() { try { //do something that can fail} catch(e) { // gracefully fail, setting portion of ui to fail state …
Robert Lemiesz
  • 1,026
  • 2
  • 17
  • 29
3
votes
2 answers

How to convert Proxy to Array in mobx-react

I have an observable variable defined in the store, and I attempt to make multiple calls and push results to the Array. When I am so doing this, I find the array I defined is a proxy so that I cannot display the info in my page. This is my…
Frank Kong
  • 1,010
  • 1
  • 20
  • 32
3
votes
0 answers

Using mobx with redux in the same project - even in the same component/class

A bit of background first: In in the process of learning react and redux, using Typescript. For components with some kind of application state (rather than pure UI state), I am trying to keep a logical separation between the react components and the…
fubaar
  • 2,489
  • 1
  • 21
  • 21
3
votes
2 answers

MobX: Observed Component does not rerender after observable change

I have a basic MobX setup in React Native, but my component does not rerender after an observable is getting updated and I can't seem to figure out why. react-native 0.56.1; react 16.4.1; mobx 4.5.0; mobx-react 5.2.8 Store class AppStore { drawer…
mxmtsk
  • 4,285
  • 6
  • 22
  • 47