Questions tagged [mobx-react-lite]

67 questions
1
vote
2 answers

In my React application, mobx @action is not firing - mobx , mobx-react-lite

I am using mobx & mobx-react-lite for first time and I can see the @action is not firing any events. Please find the Code SandBox url here My intention is when I click on button, the name CHAN should change to XIAN. But it's not happening. Can you…
METALHEAD
  • 2,734
  • 3
  • 22
  • 37
1
vote
1 answer

Can I totally get rid of useCallback and useMemo with MobX in React?

Currently, I am using Redux and the mentioned hooks for react projects. However, useMemo and useCallback can quickly lead to bugs (tricky ones) very quickly in my opinion. As I understood, these hooks are required to avoid unnecessary re-rendering…
mleister
  • 1,697
  • 2
  • 20
  • 46
1
vote
1 answer

mobx-react-lite useObserver hook outside of render

I've seen examples of the useObserver hook that look like this: const Test = () => { const store = useContext(storeContext); return useObserver(() => (
{store.num}
)) } But the following works too,…
toyko
  • 13
  • 1
  • 3
1
vote
0 answers

MobX-state-tree store is not appearing in props

I am implementing MobX-state-tree into my React Native app using MobX-react-lite. I am able to access the store directly using a hook I wrote from a tutorial I found: const useInject = (mapStore: MapStore) => { const store = useStore(); …
Tristan
  • 341
  • 4
  • 17
1
vote
1 answer

How to make child component reactive to state change in mobx using mobx-react-lite

I'm using mobx-state-tree and mobx-react-lite, can someone guide me to a better pattern, wishlist.js - wishlist store import { types } from 'mobx-state-tree' export const WishListItem = types.model('WishListItem', { name: types.string, price:…
AviKKi
  • 1,104
  • 8
  • 16
1
vote
1 answer

Mobx: Change values of a store from another store

I am using mobx-react-lite with hooks. I have two store. AuthStore SomeOtherStore This is my dummy AuthStore import { observable, decorate, action } from 'mobx'; import { createContext } from 'react'; import { ROLE_LOGISTICS_MANAGER } from…
Sarmad Shah
  • 3,725
  • 1
  • 20
  • 42
0
votes
0 answers

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 selected model and It should get reflected in the UI…
0
votes
0 answers

Why are my React components duplicating with MobX store implementation?

I started learning React and so I'm making an app that performs CRUD functions on activities. I'm using MobX lite to manage the app's state. When I load activities using the loadActivities method from the activityStore.ts, the activities duplicate,…
Lukas
  • 1,699
  • 1
  • 16
  • 49
0
votes
0 answers

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 array called ClotheTypePriceList. The…
Irfan Arif
  • 25
  • 6
0
votes
0 answers

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 a particular store (class) in a single component…
rai-dev
  • 1
  • 1
0
votes
3 answers

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 line 11 with line 12) the component name…
Matt
  • 1,368
  • 1
  • 26
  • 54
0
votes
1 answer

Mobx Store does not update rows in AGGrid

I want to use mobx store for state management. I want to update record in the store and it should be reflected in the grid. I have method updateRecord which is updating the store but the AGgrid does not get updated. Another method deleteRecord works…
Raj
  • 91
  • 5
0
votes
1 answer

Feedback on testing approach of MobX store in React

I am new to testing MobX stores in React with Jest. I have read this and this, but these posts are focused on testing components with the stores and not the stores themselves. What would be the best approach for unit testing the stores in isolation…
AAMCODE
  • 415
  • 1
  • 7
  • 20
0
votes
1 answer

I'm trying to build a production version with yarn then I get this error: Type error: Property 'store' does not exist on type '{}'. How can I resolve?

So the error is from this Qwerty component, Giving Error: Property 'store' does not exist on type '{}' ``` import { observer } from 'mobx-react-lite' export default observer(function Qwerty({store}) { const qwerty = ['qwertyuiop', 'asdfghjkl',…
Laban Bwire
  • 81
  • 2
  • 7
0
votes
1 answer

Does useLocalObservable in MobX make its getters computed values?

I noticed that useLocalObservable makes functions into mobx actions automatically, the same way that makeAutoObservable does for classes. Does it also make getters into mobx computed values? import { useLocalObservable } from…
Evan Summers
  • 942
  • 4
  • 13