Questions tagged [mobx-react-lite]

67 questions
0
votes
1 answer

Mobx React `autorun` called more times on every change

I've setup a simple app store with a single numeric value, which I increment on every button click. My UI is simple: a single app
which contains a MyChild component that renders the number next to an increment button. The app's autorun seems…
Sagi Mann
  • 2,967
  • 6
  • 39
  • 72
0
votes
1 answer

mobx-react-lite: Cannot read properties of undefined

I have a simple component that just adds value in screen, but I'm receiving an error: Uncaught TypeError: Cannot read properties of undefined (reading 'value') at increment (initialState.js:11:7). App.js: return (
0
votes
2 answers

Mobx: Calling an action that depends on an observable in a different store, from a React useEffect

I have an application that needs to be authenticated with an API service before I can make any subsequent calls. So, when the page loads, I call the authApp() action from a useEffect hook. Once the call succeeds, I get a token in the…
aadlc
  • 735
  • 1
  • 12
  • 26
0
votes
1 answer

MOBX is concatenating an observable instead of updating it

I am building a login page with Mobx, MUI V5, react-router V6 and react-hook-form. My first API call is to authenticate the application, apiAuth() will return a token that needs to be passed to all subsequent API calls. On the next call, userAuth(),…
aadlc
  • 735
  • 1
  • 12
  • 26
0
votes
1 answer

Why mobx computed getter doesn't call after change value

I have TestStore and observable property fields. When I click to any name, i call action changeOneName and change some object inside fields. Computed getter hasError called again and i see console.log("hasError computed"); Why don't I see …
KAVA
  • 197
  • 1
  • 4
  • 16
0
votes
2 answers

why chatMsgStore.addChatMsg(bdmsg) does not effect the store?

store.js import {useLocalObservable} from "mobx-react-lite"; function chatStore() { return { chatmsg: [], setChatMsg(arr) { this.chatmsg = arr }, addChatMsg(msg) { this.chatmsg.push(msg) …
user2177459
  • 97
  • 3
  • 9
0
votes
1 answer

Mobx. Getting value from another store

I have Mobx FirstStore and import SecondStore. SecondStore has a (value) and I want to use it (value) in my FirstStore. As shown in the screenshots, this is how it works, but I have a question, is it safe to use it? If (value) changes in my…
EmilM
  • 107
  • 1
  • 3
  • 11
0
votes
1 answer

How correctly fetch data by id using React mobx lite?

I wrote some code with MOBX! Now I have an input field and I take that value and send that string to API and fetching data! afterward, I get data from the store but it doesn't refreshing when I write new city in input! I want to add city in input…
Sergo
  • 43
  • 1
  • 5
0
votes
2 answers

Mobx async example does not render result after action

You can look at the issue via codesandbox Codesandbox: https://codesandbox.io/s/great-frog-m2s7h Context I am trying to fetch some data and populate some variable and render the value in React, essentially following the documentation await/async +…
0
votes
0 answers

beforeExit hook not present in ep-mobx-router

I am using ep-mobx-router v0.2.3 in a react typescript project, which is very similar to mobx-router. The documentation page shows that beforeExit is a hook present in the package, but when I am trying to use it, it gives error that its not present…
JSDrogon
  • 31
  • 8
0
votes
0 answers

React Router link isn't working in Menu.Item element in ReactJS & Mobx using react-router-dom

I'm trying to route in a react app using react-router-dom but it seems there is a problem when I try to put a link in a menu item element it doesn't respond at all. Here is the code below of navbar.tsx import React, { useContext } from…
0
votes
1 answer

Mobx model type for hashmap

I want my model variable to look like { "foo": { "viewed": false, "url": "https://www.google.com" }, "bar": { "viewed": false, "url": "https://www.google.com" }, "baz": { "viewed": false, …
elcapitan
  • 145
  • 1
  • 2
  • 13
0
votes
0 answers

Mobx observable fields not updating in observer( UI ) when used with React hooks

I'm creating a simple React app with react-hooks using a mobx store. The packages I'm using here is mobx and mobx-react-lite. When I click on the Add/Multiply buttons, nothing happens. The updated count value is not reflecting. Am I missing…
0
votes
1 answer

observer from 'mobx-react-lite' not working

I just started to practice react mobx and now I have a problem. the observer not working. it seems it not observing the store. this should load some activity list from api and during loading show the icon (loading). and after loaded datas it should…
siyavash
  • 168
  • 2
  • 14
0
votes
1 answer

Updating Todo list via mobx with react and typescript

Hi guys i was just trying out mobx today and made a Todo List with it, the problem is the list isn't updating here after the item is removed from the list even though i had made observer and observable. You can also directly check my code here at…
Ratnabh kumar rai
  • 1,426
  • 4
  • 21
  • 48