資源:html
1. Redux 中文文檔node
Redux 中文文檔react
2. Atom文本編輯工具android
Atom文本編輯工具git
3. React-native 官方文檔github
問題:redux
1. npm並非每個version均可以安裝react-native, 以前安裝的時候發現最新版並不能安裝,後來使用另外一個工具(待回憶)安裝了npm的5.9.x的某個版本以後才能夠安裝。目前我使用的6.2.2也是能夠的。react-native
2. mac上會出現react-native指令不識別問題。bash
react-native: command not found:
首先用npm install -g react-native-cli獲得react-native的安裝路徑,以下
Enter: npm install -g react-native-cli output: /usr/local/Cellar/node/6.1.0/libexec/npm/bin/react-native ->/usr/local/Cellar/node/6.1.0/libexec/npm/lib/node_modules/react-native-cli/index.js/usr/local/Cellar/node/6.1.0/libexec/npm/lib └── react-native-cli@0.2.0
再在bash裏面輸入:export PATH="/usr/local/Cellar/node/6.1.0/libexec/npm/bin:$PATH"
就能夠正常使用react-native的命令了。
至於其餘大神說的.bashrc .bashprofile等等,我也是剛開始用imac,沒找到也沒搞清楚到底怎麼弄。
參考:http://stackoverflow.com/questions/33282545/bash-react-native-command-not-found
學習筆記:
和已有app的集成:
主要參考Integration With Existing Apps:http://facebook.github.io/react-native/releases/next/docs/integration-with-existing-apps.html
也有一些這裏面沒說起到的問題須要處理
1. npm相關命令是在項目根目錄的上一級目錄執行,而不是在根目錄中執行。
2. "start": "node node_modules/react-native/local-cli/cli.js start" 注意跟前面其餘內容加一個,號
3. For debug, 在Manifest里加入<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
4. 在Application中實現ReactApplication
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage()
);
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
}
5. 在繼承的ReactActivity中須要指定MainComponentName:
/** * Returns the name of the main component registered from JavaScript. * This is used to schedule rendering of the component. */@Overrideprotected String getMainComponentName() { return "HybirdTest";}