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
41
votes
6 answers

Can't call setState on a component that is not yet mounted

this is the first time I face this warning message. Can't call setState on a component that is not yet mounted. Follows: This is a no-op, but it might indicate a bug in your application. Instead, assign to this.state directly or define a state =…
Kev
  • 4,017
  • 4
  • 26
  • 47
23
votes
5 answers

React-MobX Error: The 'decorators' plugin requires a 'decoratorsBeforeExport' option, whose value must be a boolean

I get the following error: If you are migrating from Babylon/Babel 6 or want to use the old decorators proposal, you should use the 'decorators-legacy' plugin instead of 'decorators'. package.json "@babel/plugin-proposal-decorators": { …
KNIGHT MAHAJAN
  • 399
  • 1
  • 2
  • 11
19
votes
2 answers

How to inject mobx store into a stateless component

I am using mobx and react in a web application and I want to find a way to pass mobx store state to a stateless component. Below is my current component source code: import React from 'react'; import Panel from './Panel'; import {inject, observer}…
Joey Yi Zhao
  • 23,254
  • 37
  • 138
  • 276
18
votes
3 answers

mobx + react unexpected token

so i created an app with react without configuration from https://facebook.github.io/react/blog/2016/07/22/create-apps-with-no-configuration.html I installed mobx and mobx-react ,but is still shows the error of unexpected token before @ symb. Do I…
Elīna Legzdiņa
  • 297
  • 1
  • 3
  • 11
17
votes
3 answers

Property 'profileStore' is missing in type '{}' but required in type 'Readonly'.ts(2741)

I am using mobx react a type script Why does show the error Do i just need to set default props? Property 'profileStore' is missing in type '{}' but required in type 'Readonly'.ts(2741) MainNote.tsx(9, 3): 'profileStore' is…
Hello-World
  • 7,619
  • 22
  • 71
  • 144
15
votes
2 answers

Why do I need to use Context or a Provider with MobX?

I am trying to learn how to use MobX with React, and I don't understand why using a Provider or Context is necessary, if the object that holds the state never changes, only its contents. E.g. I have a store (a simple timer that changes over time) in…
RemcoGerlich
  • 27,022
  • 4
  • 55
  • 74
14
votes
3 answers

Mobx-State-Tree - Assign to Array Type

I have this basic model. const stuff = types.model({ term: types.string, excludeTerm: types.string, stores: types.array(types.string) }).actions(self => ({ setTerm(term: string) { self.term = term }, setExcludeTerm(term: string) { …
etudor
  • 823
  • 9
  • 17
14
votes
1 answer

What is the best way to create a single MobX store for an app?

I have been using MobX and Redux for about 6 months. I have found that I prefer the simplicity of MobX for most applications. However, I like the single store concept of Redux. I have heard others comment that they create a single story with MobX…
Tanner Plauché
  • 165
  • 1
  • 10
13
votes
4 answers

Hitting Back button in React app doesn't reload the page

I have a React app (16.8.6) written in TypeScript that uses React Router (5.0.1) and MobX (5.9.4). The navigation works fine and data loads when it should, however, when I click the browser's Back button the URL changes but no state is updated and…
Chris Tybur
  • 1,544
  • 1
  • 22
  • 36
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
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
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
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
11
votes
2 answers

What are the advantages and disadvantages of mobx and Redux, particularly in a React-Native environment?

Lately I've been hearing everyone talking about mobx, I've used (am using) Redux in a production React Native application. I'm just looking to see if anyone has experience with both and can advise where each one holds advantages over the other.
R. Langford
  • 154
  • 1
  • 8
1
2 3
49 50