Questions tagged [mobx-react-lite]
67 questions
1
vote
1 answer
Mobx Out of bounds read: 2 - React-Native
I am using my mobx in my React-native app.
mobx: "^6.6.2",
mobx-react-lite: "^3.4.0",
mobxStore.js
this.arr = [];
getArray(){
return this.arr;
}
const temp = appState.getArray();
When fetching state array, I am getting this warning many…

Jemish Rajpara
- 119
- 1
- 3
1
vote
1 answer
How to use a typescript type as a property type inside Mobx State tree model
I am using a Qraphql code generator that generates the schema types in typescript and would like to use those types inside the model.
My question is how can I use a typescript type inside the Mobx state tree model like this
type AssignedFilter = {
…

Yassir Hartani
- 157
- 1
- 6
1
vote
0 answers
Testing React/Typescript Component with MobX store
I am testing a React/Typescript component using Jest and React Testing-Library while using MobX as a state manager.
I am aware that RTL has docs for creating a custom render for testing, but not sure how to do this while using MobX. I think I have…

AAMCODE
- 415
- 1
- 7
- 20
1
vote
0 answers
Child component not re-rendering on Mobx observable/compute change
I have a store file named Authstore.js as below
import { observable, computed, action, makeObservable } from 'mobx';
export default class AuthStore {
constructor(stores) {
makeObservable(this);
this.stores = stores;
this.stop();
}
…

Sathish
- 87
- 1
- 1
- 6
1
vote
0 answers
React.js and Mobx. 'TypeError: cyclic object value' if i try to find item in the mobx collection
My mobx class:
class ProductItems {
products = [
{ id: 1, image: window.location.origin + '/images/tmp/01.png', price: '₴184.21' },
{ id: 2, image: '/images/tmp/02.png', price: '₴311.21' },
{ id: 3, image: '/images/tmp/03.png', price:…

Sergii
- 7,044
- 14
- 58
- 116
1
vote
1 answer
Is it possible to listen to actions?
For example
There is a store:
const DataStore = observable({
data: [],
getDataAction() {}
})
And there are also other stores.
All of them are used in:
injectStores({ store, storeY })
in order to MobX DevToolsPro work.
Official documentation…

AnonymFromInternet
- 63
- 4
1
vote
1 answer
How to trigger a state like setState with MobX, mobx-react-lite?
I want to carry to states into the global state with mobx. I'm struggling to create a global state in mobx. Also, I would like to mention that I'm using mobx-react-lite library.
Here is the link to codesanbox. If you open the commands, you will be…

ffcabbar
- 351
- 1
- 3
- 18
1
vote
1 answer
How to combine a global MobX store with local state in the component?
I have the next component:
const App = observer(({injector}: Props) => {
const preferences = injector.getPreferences().execute()
const themeStore = useLocalStore(() => ({
_theme:
preferences.theme === ETheme.DARK
?…

Denis Sologub
- 7,277
- 11
- 56
- 123
1
vote
1 answer
How to use observer to wrapper react custom hook?
In my project, I create a custom react hook that needs to use observable state in store for dependencies of useEffect:
My example custom hook:
const useFoo = (() => {
const { count } = store;
useEffect (() => {
//do something here
…

HauLuu
- 19
- 2
1
vote
1 answer
extending of observable subclassing: [MobX] Options can't be provided for already observable objects
When I create a deep structure with few extends I got this kind of error:
Uncaught Error: [MobX] Options can't be provided for already observable objects.
"mobx": "^6.4.2",
"mobx-react-lite": "^3.3.0",
All of code is just dirty example. real…

Max Korniiov
- 11
- 1
1
vote
1 answer
Why Mobx observer is not triggering re-render on React recurrent component?
I am trying to create a recursive component that stores it's state in a mobx observable object.
For some peculiar reason, if the observable links another observable in it's properties, the observer hoc from mobx-react-lite does not trigger…

Daniel
- 1,431
- 2
- 16
- 36
1
vote
2 answers
Is it advisable to use mutable operations for array in mobx?
Every time in react I care about immutable array operations
to avoid accidental state changes via mutable operations
I often use immutable operations
whenever I need to add a new item I use this
[...myArr, 'newItem'];
instead of mutable…

Hidayt Rahman
- 2,490
- 26
- 32
1
vote
1 answer
Observer does not work for recursive items
I'm really stuck with the problem. I have a nested menu. After click on the first menu level second level items shows up. After click on one of the children nothing happens. Looks like the observer don't work for deep levels items. I don't know if…

Spencodromix
- 43
- 4
1
vote
0 answers
MobX class store vs functional store
What is the difference between Mobx 6 class store vs functional store?
class store
export class UserStore {
username;
role;
constructor() {
makeAutoObservable(this)
}
}
function store
const store = useLocalObservable(() =>…

s1n7ax
- 2,750
- 6
- 24
- 53
1
vote
0 answers
mobx-state-tree invalid type definition for property 'lessons', it looks like you passed on object
This is the model that is expecting the lessons:
export const LessonModel = types.model({
is_imported: types.boolean,
})
const CalendarStoreModel = types.model('newCalendarStore',{
lessons: types.optional(types.array(LessonModel),[]),
…

meowzart
- 75
- 1
- 8