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

1624 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
32
votes
3 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…
archae0pteryx
  • 3,124
  • 2
  • 17
  • 38
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,337
  • 5
  • 23
  • 48
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
16
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
  • 359
  • 2
  • 13
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
15
votes
5 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
  • 555
  • 8
  • 16
15
votes
9 answers

How to get MobX Decorators to work with Create-React-App v2?

Support for the experimental syntax 'decorators-legacy' isn't currently enabled I tried adding the decorators-legacy babel plugin and @babel/plugin-proposal-decorators with { legacy: true } in .babelrc but no effect. Anyone managed to get MobX…
J. Reku
  • 285
  • 1
  • 3
  • 13
15
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
  • 287
  • 1
  • 2
  • 11
15
votes
3 answers

Using the MobX @action decorator with async functions and .then

I'm using MobX 2.2.2 to try to mutate state inside an async action. I have MobX's useStrict set to true. @action someAsyncFunction(args) { fetch(`http://localhost:8080/some_url`, { method: 'POST', body: { args } }) .then(res…
twsmith
  • 301
  • 3
  • 14
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
2 answers

How to use mobx in react-native 0.56 (Babel 7) with Decorators

i've upgraded my RN app from 0.55.4 to 0.56 that use Babel 7. In 0.55.4 to use decorators for MOBX i use "babel-plugin-transform-decorators-legacy" but is not compatible with Babel 7... react-native ver: 0.56.0 mobx ver: 5.0.3 mobx-react ver:…
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
1
2 3
99 100