專案架構介紹與開始前的準備
Last updated
Was this helpful?
Last updated
Was this helpful?
基於 做的修改
原本的index.android.js 與index.ios.js 整合至index.js
打包常用的library (redux / immutable)
開發時常用command
yarn add some-plugin@version
安裝第三方套件
yarn start
(react-native start)
開啟react-native packager 負責打包成js bundle 並傳送至裝置端
react-native link
將需要設置的native module 對 native project (android/ios) 進行library 的設置與package 引用修改
yarn run android
(react-native run-android)
打包android source 並安裝在裝置上,需要準備android sdk 與 build tool 才有辦法打包,開發時只有在native project 有變更時,才需要進行打包,其他時間code 的更新都是透過 yarn start
開啟的packager
react-native log-android
console.log
console.warn 在裝置上黃色框框
常見順序:
yarn add some-third-party-native-plugin
react-native link
react-native run-android
開發前的準備
打開 Dev menu 中的 Hot reloading 或 Live reload , Genymotion 使用 Menu 鍵,實體android 手機搖一搖
Hot reloading 只更新更動後的.js ,保留畫面的state,並不會執行constructor 與 componentDidMount,所以 ,部分UI 不適用 e.g FlatList 的 renderItem
Live Reload, 一有檔案更動直接App 重 load ,效果等同於 手動觸發reload
參考資料:
安裝prettier, eslint ,並設定之
如果是windows ,關掉.eslintrc 的linebreak 的 check
"linebreak-style":0
BasicComponent (component.js)
FlatList (list.js)
High-order Component (hoc.js)
(錯誤範例)
Adjacent JSX elements must be wrapped in an enclosing tag
(正確範例)
Cannot add a child that doesn't have a Yoga Node to parent without a measure function
(錯誤範例)
可參考
使用