Mobx: React components not reacting to observable appState

Created on 17 Sep 2016  路  2Comments  路  Source: mobxjs/mobx

I have cloned the mobx-react-boilerplate and added react-router component. The new repo is mobx-react-router-boilerplate.

There are two components (BlueCounter, RedCounter) linked as two routes, showing the count value from the appState. The two components represent two pages. I have used the Provider from mobx-react

I am facing an issue when declaring AppState as a class and creating an instance of it, the blueCounter does not react to the actions and changes, It only show the updated value after transitioning to the RedCoutner and back to the blue one.

On the other hand, if I used the observable({}) way (which is shown in AppState2), components reaction works fine and they get updated, am I missing something in the code ?

馃檹 help wanted

Most helpful comment

@yasirhantoush, you should place transform-class-properties after transform-decorators-legacy in your .babelrc

All 2 comments

@yasirhantoush, you should place transform-class-properties after transform-decorators-legacy in your .babelrc

Thanks @andykog , it is working perfectly now, I will update my repo, and close this ticket
Thanks again for the help.

Was this page helpful?
0 / 5 - 0 ratings