@observer got an syntax error
I got this syntax error for use mobx-react in react-native. Anyone know what's happened
?

This is my code
Not familiar with RN projects setup, but where is the babel configuration? .babelrc or something like that
@mweststrate, people are usually using react native packager, with exclusive (babel-preset-react-native)[https://github.com/facebook/react-native/blob/master/babel-preset/configs/main.js], I'l try to check @Zcgong's example
@Zcgong, I see you are using decorators without any configuration for that. I, personally, haven't managed to get it working with react native packager. And they saying that decorators won't work until T2645 lands in Babel. So thats not a mobx issue.
After 2 chages you app is working for me:
// before:
@observer
export default class App extends Component {
}
// after:
class App extends Component {
}
export default observer(App);
// before:
@list = []
// after:
constructor() {
extendObservable(this, {
list: [],
});
}
@andykog Thanks ! I will try this.
@andykog Thanks a lot ! I fix this by two way:
- add .babelrc file add plugins "transform-decorators-legacy"
- your way
but I feel confuse with the first way, did it must add at the project init ? I try to add it in my current project but it not works. Then I init a new project and add it then copy code to this new , it works. Why ?
@Zcgong, I guess, your last question is about react-native packager, not mobx-react. Try to google react-native packager transform-decorators-legacy
Thankyou all sir, is working..