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

1876 questions
51
votes
7 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
  • 5,049
  • 5
  • 32
  • 53
46
votes
1 answer

Mobx - runInAction() usage. Why do we need it?

I have read various websites regarding this topic but I haven't managed to figure out why do we need the runInAction method and how exactly does it work. Can someone explain to me runInAction functionality? Thanks.
user7479651
  • 689
  • 1
  • 5
  • 14
39
votes
4 answers

The connection to _next/webpack-hmr was interrupted while the page was loading

Using Next.js - building this I am porting my app to the next.js framework. Currently, I am re-creating the authentication system, otherwise, this iteration of my app is pretty bare-bones. All of a sudden, after adding my protected routes (Higher…
rimraf
  • 3,925
  • 3
  • 25
  • 55
32
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
  • 1,183
  • 1
  • 11
  • 19
30
votes
3 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
  • 37,514
  • 71
  • 268
  • 523
28
votes
3 answers

MobX: Since strict-mode is enabled, changing (observed) observable values without using an action is not allowed

My context looks like this: class AuthStoreClass { authUser = null constructor() { makeAutoObservable(this) } login = async (params) => { const { data: { data: authUser } } = await loginUser(params) …
mleister
  • 1,697
  • 2
  • 20
  • 46
28
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
  • 30,470
  • 6
  • 61
  • 79
23
votes
4 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
  • 598
  • 26
  • 81
  • 173
21
votes
6 answers

MobX vs. MobX State Tree

Why should I use MobX State Tree over vanilla MobX? It seems like any time I read about MobX, MST is mentioned in the same place. Is anyone actually using just MobX by itself? Probably too general of a question...
John
  • 705
  • 3
  • 9
  • 18
20
votes
4 answers

How to connect state to props with mobx.js @observer when use ES6 class?

Let's take a class like this in an app with React and React Router. @observer class Module1 extends React.Component { constructor (props) { super(props); //... } componentWillMount(){ //... } method(){ //... } …
dagatsoin
  • 2,626
  • 6
  • 25
  • 54
19
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
  • 433
  • 1
  • 4
  • 12
18
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,925
  • 7
  • 24
  • 41
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
  • 307
  • 1
  • 3
  • 11
17
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,612
  • 2
  • 23
  • 38
17
votes
2 answers

When to use computed/observables in mobx

I feel like I'm getting most of mobx, but I want to clarify something. I've got a store with some observables, the core of which is an array of objects (typescript): class ClientStore { constructor() { this.loadClients(); } …
Jakke
  • 317
  • 1
  • 3
  • 11
1
2 3
99 100