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
0
votes
1 answer

Proxy in mobx -state-tree

I'm trying to build a simple budgeting app. Whenever I insert this model into my app. I get a proxy for the expenses. Where is the flaw in my thinking? I have an action on the Budget.js when I print it in the useEffect this is what console.log…
Shekib
  • 11
  • 4
0
votes
1 answer

observer mobx-react seems not working in React

I am a starter to React and mobx. Based on my design, data should be updated after click the button using observer, observable modules. Even though the console log displays the email changed whenever clicking the button, the view doesn't change at…
CalgaryFlames
  • 678
  • 2
  • 10
  • 30
0
votes
1 answer

MobX not updating React Component when computed array is changed

I have a list of todos in store which is not sorted. A computed value is added to store that returns sorted todos. The React Component is using sortedTodos to display the list. Whenever the todos list changes, the component is not re-rendered, if I…
Gurleen Sethi
  • 3,162
  • 6
  • 26
  • 48
0
votes
1 answer

Sorting by A-Z and Z-A MobX

I want to use same button for sorting A-Z and Z-A. For now my sort only work for A-Z, and I am not sure how to make it work both way A-Z and Z-A on same button. For now first click sort A-Z and second click doesn't do anything. Can somoene please…
Ivan Radunković
  • 105
  • 1
  • 3
  • 15
0
votes
2 answers

Mobx and React. No support for experimental syntax

I have problem with Mobx syntax. This is my first project with Mobx. I've got message: "Support for the experimental syntax 'decorators-legacy' isn't currently enabled" What shoud I do? How should syntax look? Or syntax is good and I should do this:…
Ivan Radunković
  • 105
  • 1
  • 3
  • 15
0
votes
1 answer

Debounce mobx-react and props

I'm trying to debounce the method call: "chart.calculateChartData(props.answers)". I tried: - autorun - reaction - use-debounce from a react lib. - setTimeout within calculateChartData Each solution led to an update cycle or didn't work because MobX…
im4ever
  • 469
  • 1
  • 4
  • 14
0
votes
1 answer

Is there any way to keep React from re-rendering for each item added to a MobX observed array (using Hooks)

I'm still relatively new to React so this may not be an issue or one that's solvable. I put together a very contrived (don't judge :P) experiment using Mobx and React (hooks) here. What I am wondering is if there is any way to avoid the need to…
Chance
  • 11,043
  • 8
  • 61
  • 84
0
votes
1 answer

why useObserver hook won't rerender twice, comparing to observer hoc?

I'm reading the docs of mobx-react-lite and confusing with the difference between observer hoc and useObserver hook. According to the docs, observer hoc will trigger re-render twice while useObserver won't: One good thing about this is that if any…
lamhoit
  • 3
  • 2
0
votes
1 answer

Use optimized es6 build of MobX for React Native in Metro config

I'm trying to use the optimized, es6 build of Mobx, as per the documentation: Tip: the main entry point of the MobX 5 package ships with ES5 code for backward compatibility with all build tools. But since MobX 5 runs only on modern browsers anyway,…
t.888
  • 3,862
  • 3
  • 25
  • 31
0
votes
1 answer

error decorators-legacy. Not vorking mobx+react js

I want use React js+Mobx but I'm getting an error ERROR ./src/stores/Todo.js SyntaxError: C:\Users...example path\Todo.js: Support for the experimental syntax 'decorators-legacy' isn't currently enabled (9:5): [enter image description…
0
votes
1 answer

Mobx Initial Data from Server

How can I set the value of mobx store from server side as initial value (from fetch/http)? import { computed, observable } from 'mobx'; import { Instrument } from '../models/core/instrument'; class ObservableInstrumentStore { //should set init…
Arun Gopalpuri
  • 2,340
  • 26
  • 27
0
votes
1 answer

What's a good practice to call an action from another action of the same model in mobx-state-tree?

I am trying to wrap multiple functions inside one. I have a model like this: const CookModel = types.actions(self =>({ talkToSousChefs:() => { // talk to sous-chefs }, talkToWaiters: () => { // business logic }, talkToVendors: ()…
Lil E
  • 388
  • 5
  • 23
0
votes
1 answer

How to package a react component on npm without store

I've been reading articles about how to publish react components to NPM, but I'm confused about the details when the component has a store implemented using a library like mobx. Take a simple example like the component you can see in its entirety…
Scott
  • 458
  • 4
  • 10
0
votes
1 answer

Having separate files for actions but using one store in Mobx. (React-Native)

i was thinking of using multiples files to store my actions in Mobx. React-Native something like this: //store.js export default class Store { @observable property = "change me"; } //loginActions.js export default class LoginActions { …
Surafel
  • 675
  • 4
  • 11
  • 24
0
votes
1 answer

Mobx Class Cannot read property 'loading' of undefined

Used create-react-app to create the react-app So I'am using mobx with react and created the following class: import { action, decorate, observable } from "mobx"; class AuthStore { loading = false; login() { console.log(this.loading); …