-
Notifications
You must be signed in to change notification settings - Fork 0
How to setup react native 0.2 with babel 6 (Android)
After trying lots of boilerplate found on the web, I finally decided to write my own, because i didn't found a functional react-native 0.2 with babel 6 boilerplate.
The solution is simpler than i thought ( thanks to react-native babel preset )
- react-native: How to Install
- android: How to install
At this point, we need either an android virtual device or a physical android device.
To check this, running :
$ adb devices
should return something like :
List of devices attached
07bdb2f7 device
- init a new react-native project
- install babel stuffs
- configure .babelrc
react-native init myApp && cd myApp
npm install react-native-cli babel babel-core babel-preset-react-native babel-preset-stage-0 --save-dev
echo '{ "presets": ["react-native", "stage-0"] }' > .babelrc
Just add this scripts to package.json :
"scripts": {
"android": "react-native run-android",
"start": "npm run cleanCache && node node_modules/react-native/local-cli/cli.js start",
"cleanCache": "rm -rf $TMPDIR/react-*"
},
To see if it's really working, let's try importing my Fjs library.
npm install guillaumearm/Fjs --save
add this lines in index.android.js :
import * as F from 'Fjs'
console.log(F)
run the packager:
npm start
If the application is not launched in your device, use:
npm run android
It could take a while.
At this point, you should have the default hello world displaying on your device, not really awesome, but if it works, you can work with babel 6 and his presets react-native and stage-0 :)
You can directly use my react_native_android_boilerplate