React-Native學習筆記


資源:

1. Redux 中文文檔

  Redux 中文文檔

2. Atom文本編輯工具

    Atom文本編輯工具

3. React-native 官方文檔

    React-native 官方文檔

 

問題:

1. npm並不是每一個version都可以安裝react-native, 之前安裝的時候發現最新版並不能安裝,后來使用另一個工具(待回憶)安裝了npm的5.9.x的某個版本之后才可以安裝。目前我使用的6.2.2也是可以的。

2. mac上會出現react-native指令不識別問題。

 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.
*/
@Override
protected String getMainComponentName() {
return "HybirdTest";
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM