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

Mobx observe only specific objects in array

I have a store with events export class EventStore { @observable events: Event[] = []; @action addEvent(event: Event) { this.events = [...this.events, event] }; }; My Event look like this : export class Event{ …
Xero
  • 3,951
  • 4
  • 41
  • 73
0
votes
0 answers

Restoring MOBX store from async storage is occasionally erroring out

I am trying to persist my mobx state in my react native app. It works most of the time but there are often errors where I have to create empty stores and lose the state. I would love some advice on how to better achieve this or if anyone has any…
elcapitan
  • 145
  • 1
  • 2
  • 13
0
votes
2 answers

Mobx rootStore and children stores

I have a root Mobx store, with some children substores. Is there any way for me to pass just root store into React components, and from that component get access to children store's values as if this property was in root. What I mean exactly is, for…
Leonid Gordun
  • 361
  • 1
  • 4
  • 14
0
votes
1 answer

Close showModalBottomSheet in flutter programmatically after a condition is satisfied - setState() or markNeedsBuild() called during build

I'd like to close a showModalBottomSheet when a boolean condition is verified as true in the code. The intended behavior is working, though, on the debug console of VSCode I'm seeing an exception being thrown, and I'm afraid it can lead to certain…
satler
  • 75
  • 3
  • 11
0
votes
1 answer

Use MobX @inject with Context API in functional components

How can I implement @inject and observer in functional child components without explicitly importing the store with context and destructuring it. Repo and Deployed site…
hildakh
  • 23
  • 3
0
votes
0 answers

Updating map type model in Mobx State Tree is causing memory leak

In my store I am updating my model like this. With every update the memosry consumption is increase by several times Here is my code which is causing memory leak: self.employees.set(empId, EmployeeMode.create({...empData})); self.employees is of…
Rahul
  • 5,594
  • 7
  • 38
  • 92
0
votes
1 answer

How do I get mobx to update when I change a property in an ObservableList?

I currently have been using mobx for my flutter app, and I'm trying to update a ListTile to change it's colour onTap. Right now I have I have an ObservableList marked with @observable, and an @action that changes a property on an item in that…
0
votes
1 answer

Caching asynchronous data

I recently found two libraries that perform this task https://github.com/tannerlinsley/react-query https://github.com/vercel/swr But they use a different approach that does not require stores, is there something similar for MobX? To set the cache…
Pavel
  • 2,103
  • 4
  • 23
  • 41
0
votes
1 answer

how to have seperate admin store that is not loaded by a non admin user?

I want to create a mobx store that is only loaded by admin users. It will only be injected into anything along the /admin route. I've looked into the use of Nested Providers but without much luck. Ideally I'd like it to be linked to the route, so if…
Marc Frame
  • 923
  • 1
  • 13
  • 26
0
votes
0 answers

ReactJS, Mobx: How to force complete, refresh-like reload of a single component?

Quick note: I already know how to refresh a component by the methods of changing state, changing the key, and calling forceupdate. For testing purposes, I want to simulate a page refresh, but only for one of the components on the page. The problem…
Eric Jorgensen
  • 1,682
  • 2
  • 14
  • 23
0
votes
1 answer

MobX not updating component properly

I am kinda new to React/MobX. I am trying to create a new item from a form within my dashboard component. After creating the new item , the ssoCatalogRegistry Map and visible items array get updated in the MobX store, however the page doesn't update…
Parakoopa
  • 505
  • 1
  • 9
  • 22
0
votes
0 answers

Mobx React Reactivity with Hooks and Observer

I've updated the app to use Mobx-react 6 along with Mobx state tree. I'm not able to get the latest value inside the component when I use custom store hooks. import { observer, MobXProviderContext, useObserver } from 'mobx-react'; function…
Pavan
  • 985
  • 2
  • 15
  • 27
0
votes
0 answers

React and mobx : Use domain class in store

I try to learn the usage of mobx with react and typescript. And I want to do something but I don't know if it's possible and if it's a good practice. I want to have a store (in my case GridStore) and a domain class (Grid) like a Service/Entity…
0
votes
1 answer

How do I prevent my mobx store from resetting when switching routes?

Im using mobx to hold my login state. After logging in, navigating to a new route with react router forces my store to reset and logs me out. What am I doing wrong? https://codesandbox.io/s/staging-cache-k7c8c?file=/src/App.js
Bryan Campbell
  • 285
  • 3
  • 9
0
votes
0 answers

MobX - updating a computed array updates the list component and all the list items as well

I've been learning MobX from the docs and wanted to replicate a normalized redux store in MobX. I have a map of the authors authorsMap with the author's id as key and an array of authors' id, authorsArray, which is used to preserve order the authors…
hackhan
  • 512
  • 3
  • 7