I have a:
@asyncAction *onItemPressed(index) {
yield u.sleep(100);
})
Produces
Unexpected token (33:36)
31 | saveData = async () => u.LocalStorage.save('data', this.data)
32 |
> 33 | @asyncAction *onItemPressed(index) {
| ^
34 | yield u.sleep(100);
35 | })
Using react-native 0.51
Currently my babel.rc, though I tried various configs:
{
"presets": ["stage-2", "react-native-stage-0/decorator-support"],
}
Good question, babel configs confuse me endlessly, with all the presets I never have an idea what is going on. Just use typescript ;-)
All joking aside, I have no real clue how to setup generators in babel (I usually use CRA which has them enabled already. But you might need transform-decorators-legacy, or is that part of decorator-support?
Does onItemPressed = asyncAction(funtion * (index) {}) make a difference?
(Actually the above setup does not work with release of react-native.
I use the react-native preset + transform-decorators-legacy plugin).
Also I tried the mobx-deep-action, but something again with compilation
I tried tge asyncActio, because of eslint and because action should be named, it looks like this:
onItemPressed = asyncAction( 'onItemPressed', function * onItemPressed (index) {})
So in the meantime I use usual small actions such as removeArray, clearArray and I have some general this.s({ x }) for value variables.
Anyway, I am learning MST, there I will not have decorators.
BTW how typescript helps with babel configs?
[side note]
By avoiding them ;-). TypeScript just has features that you can turn on an off, so that is usually a lot more declarative then the build-your-own-compiler-by-composing-presets-and-plugins approach by Babel. (For the same reason TS used to be less cutting edge the BabelJS, but nowadays TS offers all the interesting language features as well)
[/side note]
Closing issue for inactivity, and the fact that there is now a babel preset :)
Most helpful comment
[side note]
By avoiding them ;-). TypeScript just has features that you can turn on an off, so that is usually a lot more declarative then the build-your-own-compiler-by-composing-presets-and-plugins approach by Babel. (For the same reason TS used to be less cutting edge the BabelJS, but nowadays TS offers all the interesting language features as well)
[/side note]