Questions tagged [mobx-react]

MobX is a battle-tested library that makes state management simple and scalable

React and MobX together are a powerful combination. React renders the application state by providing mechanisms to translate it into a tree of renderable components. MobX provides the mechanism to store and update the application state that React then uses.

Both React and MobX provide optimal and unique solutions to common problems in application development. React provides mechanisms to optimally render UI by using a virtual DOM that reduces the number of costly DOM mutations. MobX provides mechanisms to optimally synchronize application state with your React components by using a reactive virtual dependency state graph that is only updated when strictly needed and is never stale.

850 questions
3
votes
2 answers

Mobx does not rerender after an item in observable array has changed

I can not get the truth why the TableContainer|TableComponent component does not update its children properly.In a store i have an array of objects,when i am trying to update object property the Table does not update its values.If i replace whole…
Jan Ciołek
  • 1,796
  • 3
  • 17
  • 32
3
votes
1 answer

React MOBX Component Render

I just switched out this.setState to use mobx observable, because I have multiple GET requests that fetch data. This prevents the PieChart from being re-rendered every time this.setState is called. However, now the child component does not ever get…
GavinBelson
  • 2,514
  • 25
  • 36
3
votes
1 answer

Object(...) is not a function when using decorate

I am trying to make observable property by using decorate from mobx-react however, I get error: Uncaught TypeError: Object(...) is not a function at Object../src/vrp-ui/Button.js (Button.js:32) at __webpack_require__ (bootstrap…
simo
  • 23,342
  • 38
  • 121
  • 218
3
votes
1 answer

React Native restarts on home button pressed on android

When I use the app selector and go to another app and return to mine t works well. This is my App component /** * Sample React Native App * https://github.com/facebook/react-native * @flow */ import React, { Component } from 'react'; import { …
Chris Gomez
  • 6,644
  • 4
  • 18
  • 39
3
votes
0 answers

Mobx-react observer not syncing with view React Router

I have been able to use mobx successfully with my regular pages, but i had this complex page i wanted to create, so i decdied to embed 's within the component render which worked perfectly. render = () => (
3
votes
0 answers

injector: Store 'x' is not available! Make sure it is provided by some Provider

I have this App.js: render() { const hydrate = create({ storage: AsyncStorage }); hydrate('playerStore', stores.playerStore); hydrate('settingStore', stores.settingStore); // .then( // // () => console.warn('some…
b24
  • 2,425
  • 6
  • 30
  • 51
3
votes
1 answer

Using mobx store only outside of the react components render function

I have a react component that wraps a class that renders WebGL using three.js with the DOM and connects mobx store value and it changes with the class lifecycle methods. The passed in mobx store is only used outside of the components render function…
Renārs Vilnis
  • 1,160
  • 1
  • 10
  • 24
3
votes
2 answers

JS thread seems to get paused

I have a question. I am still a newbie at react-native but I can't find anything related to my question. Not in the react/react-native docs neither with google. I already had this problem in my last project, but I never finished it and also didn't…
Noim
  • 445
  • 1
  • 3
  • 20
3
votes
1 answer

MobX + React Router 4 + @withRouter alway re-render when route change

I'm using MobX @observer and @withRouter (react-router-v4) wrap page component like this @withRouter @inject('stores') @observer class Page extends Component { render() { return (
jeanzuck
  • 726
  • 1
  • 7
  • 17
3
votes
1 answer

Mobx @inject @observer order

I have a fetch in my componentDidMount that does not refresh the appState data when I do @observer @inject('appState') but it would consistently work when I have @inject('appState') @observer . At the same time, I'm getting a warning in the console…
Abdo
  • 13,549
  • 10
  • 79
  • 98
3
votes
1 answer

Why state management libraries use react's context for dependency injection?

I looked at the source code of two famous state management libraries for React and find out that both of them use React's context as a dependency container (Mobx Provider, Redux Provider). On the other hand, I find it a good practice to try to not…
alisabzevari
  • 8,008
  • 6
  • 43
  • 67
3
votes
1 answer

MobX React TypeError: Cannot read property of undefined

I am trying React with MobX. I defined fetchSources() in my store. If I put the following at the top level component it works fine. componentWillMount() { this.props.store.fetchSources() } But if I put the above same code into child level…
Shawn
  • 5,130
  • 13
  • 66
  • 109
3
votes
2 answers

Passing MobX @observable of array to React Component props of PropTypes.array

So I'm using a vanilla React UI component library and MobX as state management in my app. When I have an observable of array as data and I want to pass it down from my component (which is a mobx-react observer) to the UI library's component (which…
panjiesw
  • 156
  • 1
  • 12
3
votes
1 answer

babelrc config for es7 Decorator not working

I've been trying to make MobX work with my React project. I've followed the babelrc config and also installed transform-decorators-legacy but it seems like I'm getting Parsing error: Unexpected character @ after trying to run my project. Here is my…
Joshua Rajandiran
  • 2,788
  • 7
  • 26
  • 53
3
votes
1 answer

Spy method in react component

My component has a method .. onUpdateProperty = (key, value) => { this.state.formData[key] = value; } I want to test if after change input, this method is called... it('on update input should update formData', function () { const wrapper =…
ridermansb
  • 10,779
  • 24
  • 115
  • 226