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
4
votes
2 answers

react native mobx value is not primitive

I build react native app and I'm using mobx. into the store I have array called tools, when i try to assign values into array I get the array Encountered an uncaught exception that was thrown by a reaction or observer component, in:…
Manspof
  • 598
  • 26
  • 81
  • 173
4
votes
1 answer

Sorting arrays with MobX

We have an MobX store containing an "User" object, which have "Comments" (array) on it. { user: { name: "", comments: [] } } In our view, we want to display the comments sorted by created date in the view the bound value is…
Roger Johansson
  • 22,764
  • 18
  • 97
  • 193
4
votes
1 answer

How to re-render only deselected and selected items with MobX?

I have the following app that allows me to click on todos in a list and only have one todo selected at a time: class State { @observable todos = [ { id: '1', description: 'Do this' }, { id: '2', description: 'Do that' }, { id: '3',…
Tholle
  • 108,070
  • 19
  • 198
  • 189
4
votes
1 answer

React component does not react to mobx observable data

I am using mobX for my react native project. Please consider this store class: class Birds { @observable listOne = []; @observable fetchingListOne = false; @observable fetchErrorOne = ''; @action setListOne = () => { …
Benjamin Smith Max
  • 2,668
  • 8
  • 33
  • 56
4
votes
2 answers

MobX + React Native : way to inject stores

I'm trying to work with MobX for a new project. I started it on May 2017, and everything was working well. I had to stop, and now I go on developing it. I had to make an npm install to manage making it working, but now, I have some problem with…
John
  • 226
  • 1
  • 3
  • 14
4
votes
2 answers

How can I inject a Store to another Store in mobX

I am using mobX in combination with React and Meteor and I need to be able to use information saved in one Store in another. Specifically, I need to have a reference of Store A in Store B in order to call an action of Store A and get the information…
Tina Raissi
  • 41
  • 1
  • 5
4
votes
1 answer

MobX with React Native: store is undefined

This is my first go at using MobX so this may be a simpler problem than I imagine, but I'm not getting any errors with the things I've tried; the store is simply undefined wherever I try to use it. I've tried both importing the store directly into…
swimisbell
  • 1,419
  • 2
  • 12
  • 19
4
votes
1 answer

Difference, when observable variable is updated inside action method and plain function in mobx?

I am using MBOX for state management in ReactJS. I sometime update observable variable inside some function, than also it re-render the react component and sometime i use @action method to update the observable variable. So what it is the difference…
gaurav
  • 51
  • 6
4
votes
1 answer

How to use @Action in Mobx + reactjs?

I am confused on how to use @action in my code. class Items { @observable items= []; @action addItem() { let newItem= new Item(); items.push(newItem); } } @observer class ItemPage extends Component { constructor() { super(); …
chobo2
  • 83,322
  • 195
  • 530
  • 832
4
votes
2 answers

How to convert decorator @action to non-decorator action in MobX

I am removing decorators from my React Native app (too many issues with babel) and my actions are not working (the contained function does not run). I'm translating class actions e.g. class MyStore { //... @action myAction(param) { …
Adamski
  • 3,585
  • 5
  • 42
  • 78
4
votes
0 answers

Why I cannot get props from the Provider by mobx-react

I am tring to use the Mobx to manage my react-project's state,but I cannot get the props from the Provider by mobx-react. This is my root element(I delete the router to simplify the question): import React from "react"; import ReactDOM from…
Yingch Xue
  • 3,013
  • 2
  • 9
  • 11
3
votes
1 answer

How to persist Mobx data on NextJS

Problem After user login user details are saved in mobx state. but after page refresh those data are gone. I want to persist data on mobx state so the user data are stay on mobx state until user logout. I tried mobx-persist-store but when I go to…
3
votes
1 answer

What's the difference between mobx observer and React useEffect?

mobx claims to "automatically detect rendering of observables". On the other hand, React useEffect claims "By using this Hook, you tell React that your component needs to do something after render". So what is the difference? When do I use mobx and…
AlonBA
  • 444
  • 1
  • 4
  • 18
3
votes
0 answers

I don't know why this error occurs (@observer <-> react-router)

I'm making a program using the react-router-dom library now. However, if the URL of the site is changed using the tag, the existing observer does not work and the following error message is output. The reactive render of an observer class component…
Yjin
  • 39
  • 1
  • 2
3
votes
0 answers

Invariant Violation: No callback found with cbID 3902 and callID 1951 for module

I'm creating a library of React Native components. On my library I have this simple component import React from 'react' import {View, Text } from 'react-native' export default function App() { return Hello