Questions tagged [mobx]
Functional reactive programming library in JavaScript.
1,886
questions
0
votes
1
answer
11
views
How can I observe a list inside an observable when using MobX in Flutter?
I have a simplified situation that I can't make to work in Flutter: a MobX observable object (Book) has a list of chapters that I also want to observe so my UI is redrawn to show a new chapter just ...
-2
votes
1
answer
50
views
Next.js 14 with Mobx [closed]
How do I integrate the Next.js 14 app router with Next.js? I have integrated the Next.js 14 app router with MobX, but the UI does not update when I update the store data. Before this, I was getting an ...
0
votes
0
answers
33
views
Should I passdown useContext variables as props in a strict parent-children relationship components in React?
I have several components with a strict parent-children relationship, and some commonly used variables are accessed through useContext, which is applied directly to the MobX-State-Tree store.
I have a ...
0
votes
0
answers
12
views
How to prevent component re-rendering in Mobx's action method
import {action, makeObservable, observable, runInAction, toJS} from "mobx";
class DesignerStore {
constructor() {
makeObservable(this, {
layerConfigs: observable,
...
0
votes
1
answer
24
views
Is there a valid config for Mobx with redux devtools?
I discovered Mobx and everything is working perfect creating stores and working with this approach. However I' ve read that using redux devtools in the browser I am able to obtain visual info like if ...
0
votes
0
answers
37
views
White screen displays when I deploy react project
I have a react project and it is working properly but when I deploy it I am seeing a white screen. I am using react-router v6 in the project.
I attempted to address the white screen issue but were ...
0
votes
0
answers
31
views
Import referencing store used in context causes createRoot error
I am writing unit tests and integration tests that test my MobX stores. These stores are provided in the app by a single context provider (using the root store pattern) in index.tsx.
import "...
0
votes
0
answers
10
views
React MobX - reading values from store outside of components
I wanted to use MobX in my new project for the first time and still don't understand everything.
I have store like this:
function createStore() {
return makeAutoObservable({
value: null,
...
0
votes
0
answers
30
views
Mobx with React, store made from class works but store made from function does not
I'm following a simple counter tutorial to learn Mobx with react. This could be my lack of knowledge in javascript but I just can't seem to figure out why and if someone could help me understand why ...
0
votes
1
answer
22
views
How to get Rid of Typescript Type error in the IDE regarding object properties
Background
I created a custom hook using React and MobX.
The custom hook receives an object units of type StoreUnits and also contains a useState hook that holds an object currentUnits of type ...
0
votes
1
answer
26
views
Triggering screen monitoring calls all dio request in mobx store class
When I trigger screen monitoring(mostly when I use textfield), it calls all the dio request I use in the application. I don't know why it occurs and what it is related to. Does anyone face this kind ...
1
vote
1
answer
21
views
Issue with mobX package, package is installed but cannot be resolved
In my lately created react project I want to use mobX. I have installed mobX packages
"mobx-react": "^9.0.1",
"mobx-react-lite": "^4.0.5",
This is part of the ...
0
votes
0
answers
18
views
What is the difference between React's MobX-state-tree's types?
I'm learning React and using the MobX-state-tree (MST) state manager.
I'm also using TypeScript and want to add types to my MST models without rewriting the properties and actions, but I don't ...
0
votes
1
answer
26
views
is there an analogue of 'counstuctor' mobx in redux-toolkit?
We have a store with an application theme
We want to rewrite it in redux-toolkit
Is there something similar to "constructor" in redux-toolkit so that multiple functions can be called ...
0
votes
1
answer
131
views
Using two firebase projects in a single react native app
I have 2 firebase projects, one with a web app and another with an android app. I wanted to use both of them in my react native app. I am using the project with an android app for user management ...
0
votes
0
answers
59
views
How can I get the value I updated on one page on another page with mobx?
I want to check the index value with Mobx. Dropdown also
viewmodel.setValue(value: viewmodel.values.indexOf(value));
When I send it this way, my index value is updated on the mobx side. But when I ...
0
votes
1
answer
392
views
Exception: Error happened when building Observer, but it was captured since disableErrorBoundaries==true
I am returning below widget in my build method of StatefulWidget class in flutter app:
return Stack(
children: [
Observer(
builder: (context) {
return SingleChildScrollView(
...
1
vote
0
answers
64
views
How can I hydrate the Modx store using the Next js 13 APP catalog >=
I can't find a way to transfer to the context store because Mobx-react-lite requires hooks
./book-store.ts
// we need to enable static rendering for prevent rerender on server side and leaking memory
...
1
vote
0
answers
16
views
MobX not updating state
I have two pages:
Page1 which shows a list of Records, each Record showing a counter
Page2 which lets you update the Counter
When tapping on an item in the list on Page1, you are taken to Page2 ...
0
votes
0
answers
39
views
Mobx store has data, but when passed as props - it's becomes undefined
I have top level React component - App.js - which simplified is like this:
import React from 'react';
import { appStore } from './state/appStore';
import CartPage from './pages/CartPage';
export ...
0
votes
0
answers
38
views
Page using Theme.of(context) gets rebuilt many times Problem
I use Mobx State management in my Flutter Project. My aim is to change the theme of the application to light & dark when I press the "press me" TextButton on the AppBar. But the widgets ...
0
votes
1
answer
28
views
React sending outdated state when calling a function after event.preventDefault()
I have a react + mobx + MaterialUI frontend and I'm facing a problem involving state variables. I have a button that shound trigger a function that converts some state variables into an object and ...
0
votes
0
answers
17
views
Im using ReactNative and MobX. How to trigger component render when returning to it via GoBack()
I need to make a component re-render when returning to it. That is, when calling GoBack() in navigation. The data becomes outdated very quickly and when returning to the previous component, it is very ...
4
votes
1
answer
92
views
How do I update mobx observables atomically?
I have a store myStore which has a main method which invokes multiple methods which are setting observale value in mobx. My problem is I want to re-render my react component only after ALL the ...
0
votes
1
answer
45
views
"this" value in compute of Mobx 4 with jQuery
This is the first time I use Mobx and I'm trying to understand how it works to apply for my project (which is not React base, just use jquery to update the DOM).
I started with Mobx 4 (I need to ...
0
votes
0
answers
15
views
React native mobx is not working in class Component
// Here is my mobx store
import { makeObservable, observable, action } from 'mobx';
import {fakeLoginApi} from './Common'
class LoginStore {
username = '';
password = '';
isValidEmail=false;
...
0
votes
1
answer
39
views
Can't replace state with object in mobx store
I'm trying to replace mobx store prop with an object. The problem is that I want it to be at first non-initialized – but when I update prop (it called agreement in code) it seems mobx just don't see ...
0
votes
0
answers
19
views
MobX : How to observe only selected part of the entire store?
The variable Models will store an array of model objects.
SelectedIndex will get changed by the UI through the action setSelectedIndex.
The Action addToResult should add the incoming data to the ...
0
votes
2
answers
78
views
Using a method from the mobx store in React useMemo
I have a MobX Store that contains user role information and a method that validates the role:
class Store {
constructor() {
makeAutoObservable(this)
}
role: string = ""
...
0
votes
0
answers
44
views
Notistack works on browser but not on cypress
I am using notistack with mobx,so whenever the state changes ,the toast will be shown using the enqueuesnackbar fucntion.
After upgrading mobx to version 6 it is not working on cypress.
It seems there ...
0
votes
0
answers
64
views
Antd Dragger with paste image from clipboard
I use Antd+Mobx and I want to modify Dragger so that it receives a file from the clipboard. Main panel has image paste handler that add new file to fileList in store.
Finally, dragged files and files ...
0
votes
1
answer
36
views
How I can change a mobx state upon a receival of a background message from firebase?
In my project I have setup the firebase like this:
import { initializeApp } from 'firebase/app';
import {
getMessaging,
getToken,
onMessage,
isSupported
} from 'firebase/messaging';
...
0
votes
0
answers
45
views
Mobx state tree types.function is undefined
Is there a way to create Mobx store with navigate property? Something like this:
const navigate = useNavigate();
const location = useLocation();
const mobxStore = useMemo(() => RootStore....
0
votes
0
answers
39
views
MobX How to Initialize Store with nested models
Trouble setting/initializing store with nested models. Example below.
The problem is when I try to set the store on the parent ForumStoreModel.forums -> I will get an error because the ForumModels ...
0
votes
0
answers
20
views
Mobx Store Function Not Populating Array on Subsequent Calls
I have a Mobx store with two functions: loadClothetTypePrice and getClotheTypePriceReletedItems.
The loadClothetTypePrice function loads a list of cloth type prices from an API and sets them in an ...
0
votes
0
answers
25
views
Routing strategy in react native using stack navigator
I am new to react native and using stack navigator to for routing from React navigation.
But I have one issue which is more about my routing architecture.
My Doubt :
After completing the one action , ...
0
votes
0
answers
46
views
How to integrate MobX and react navigation
we have build an app in react native that uses react navigation and MobX.
Our app has a home page from which the user can go to an Article page. From that article page, the user can navigate to other ...
2
votes
0
answers
350
views
How can i configure mobX in my new nextJs project?
hi all i am new to nextjs and currently working on a project where i have to use mobX as a state management tool, i have configured it in a dummy project, to work around it, and in that i have passed ...
0
votes
0
answers
35
views
MobX is updating the data in the input form coming from the web socket, but I need to make a change to this field
When I receive data from the web socket, they are put into storage, and the component is wrapped in the observer function, and the received data is displayed in the input field, but when I try to make ...
1
vote
1
answer
163
views
Managing Controllers from MobX in Flutter
I am using MobX as state management to save myself from using stateful widgets but some of the screens involves controllers and those are the only components forcing me to make my widget stateful. ...
0
votes
0
answers
64
views
How do I get X-Csrftoken from cookies that were sent using the server?
I am a novice developer of React/typescript. I use axios and mobx in my project. You need to do authorization. The main problem is that I can't get the expected csrftoken. Please tell me what am I ...
0
votes
0
answers
118
views
<spyOnProperty> : isInCreateMode is not declared configurable
I have an Angular 15 application and I'm using Karma for Unit testing along with Mobx as the StateStore.
I'm mocking the following mobx code in Karma/Jasmine:
@computed get isInCreateMode(): boolean {
...
0
votes
1
answer
148
views
Flutter: How do I implement Observer( ) mobX in TextFormField?
So, I created this class where I have my @observables variables and my @action function. Everything is working right, all the returns and sets.
part 'location_controller.g.dart';
class ...
0
votes
1
answer
108
views
Need help to figure out Mobx with Next-Auth
Here are my core dependencies and it's versions from my package.json file:
"mobx": "^6.5.0",
"mobx-react": "^7.3.0",
"next": "12.1.6",
"...
0
votes
1
answer
123
views
Create a counter using next and mobx
i'm trying to create a simple counter using nextjs and mobx. But i got an error. what am I doing wrong? I checked everything a thousand times
import React from "react";
import { observable } ...
0
votes
1
answer
54
views
MobX: context is lost during fetch execution
I am writing the fetchPosts method using ModX, but I get an error related to the fact that inside fetchPosts this is undefined, although I use the arrow function. How to fix this behavior?
import { ...
0
votes
1
answer
136
views
How to get JavaScript Object with mobx toJS
My code:
configure({
enforceActions: 'always',
})
class Store {
constructor() {
makeAutoObservable(this)
}
model = observable.map({
name: 'Alex',
})
}
...
0
votes
3
answers
192
views
MobX observable component names hidden in stack trace
Here is a component that intentionally throws an error:
The App component is labelled as observerComponent in the stack track. However, if we remove the observer wrapper around our component (replace ...
0
votes
0
answers
32
views
Guarantee all actions trigger visible react observer updates
I have a series of actions I'd like to run as fast as possible while still guaranteeing react observer components update after every action, i.e. it'd be great if it just ran as close to 60fps as it ...
-3
votes
1
answer
77
views
How can I avoid component render if a value is not ready? [duplicate]
I'm showing a name on my react class component. This name it is being filled after an API call, if the API responds with none value I'm showing an "ask for the name" title on my component.
...