Skip to content

Commit c0ea226

Browse files
authored
Merge pull request #8 from kyoyadmoon/master
update 201909 docs
2 parents eb6e794 + b75f2b2 commit c0ea226

File tree

12 files changed

+267
-152
lines changed

12 files changed

+267
-152
lines changed

SUMMARY.201909.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
- [專案環境設置](setup/readme.md)
2828
- [一般環境設定](setup/environment.md)
2929
- [虛擬機環境教學](setup/VM_Setup.md)
30-
- [ESLint](setup/eslint.md)
3130
- [初始化專案](setup/initialize_project.md)
31+
- [ESLint](setup/eslint.md)
3232
- [git 常用操作指令](setup/git.md)
3333
- [網路與 HTTP Request](Network/readme.md)
3434
- [網路環境設定](Network/setup.md)

SUMMARY.md

Lines changed: 40 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,48 @@
44
- [1. React.JS 介紹](react/React_Intro.md)
55
- [2. 關鍵的 Virtual DOM](react/Virtual_DOM.md)
66
- [3. 資料與畫面的更新流程](react/React_Data_Flow.md)
7+
- [React 教學](react/readme_2.md)
8+
- [1. Expo Snack 介紹](setup/expo-snack.md)
9+
- [2. React Component - 樂高式的 UI 組合](react/Component.md)
10+
- [3. 好直覺的 JSX 語法糖](react/JSX.md)
11+
- [4. Props - 傳遞資料的媒介](react/Props.md)
12+
- [5. State - 動態更新的資料載體](react/State.md)
13+
- [6. Lifecycle - Component 的一生](react/Lifecycle.md)
14+
- [React Native 組件練習教學](components/readme.md)
15+
- [組件使用教學 - View](components/index.md)
16+
- [Image](layout/image.md)
17+
- [Button](layout/button.md)
18+
- [Input 組件的資料流管理](components/Input_Data_Flow.md)
19+
- [List](layout/list.md)
20+
- [實戰練習 ToDo List](ToDoList/index.md)
21+
- [樣式與排版設計](layout/readme.md)
22+
- [React Native Style](layout/style.md)
23+
- [View 樣式](layout/view.md)
24+
- [Flex](layout/flex.md)
25+
- [Text](layout/text.md)
26+
- [ToDo List Style 練習](ToDoList/add-style.md)
727
- [專案環境設置](setup/readme.md)
828
- [一般環境設定](setup/environment.md)
929
- [虛擬機環境教學](setup/VM_Setup.md)
10-
- [ESLint](setup/eslint.md)
1130
- [初始化專案](setup/initialize_project.md)
31+
- [ESLint](setup/eslint.md)
32+
- [git 常用操作指令](setup/git.md)
1233
- [網路與 HTTP Request](Network/readme.md)
13-
- [1. 網路環境設定](Network/setup.md)
14-
- [2. fetch HTTP request](Network/fetch.md)
15-
- [3. Lab: ToDoList RESTful API 練習](ToDoList/restful-api.md)
16-
- [使用者認證整合](Auth/readme.md)
17-
- [1. JWT](Auth/JWT/JWT.md)
18-
- [2. Lab: ToDoList JWT 練習](ToDoList/jwt-todo.md)
19-
- [3. Facebook 登入整合](Auth/SocialLogin/Facebook.md)
20-
- [4. Lab: Facebook Login 練習](Auth/SocialLogin/todo-fbsdk.md)
21-
- [Redux](Redux-advance/readme.md)
22-
- [1. Redux 介紹](Redux-advance/01-article-Redux介紹/readme.md)
23-
- [2. 為什麼需要 Redux](Redux-advance/02-article-為什麼需要Redux/readme.md)
24-
- [3. 三大原則](Redux-advance/03-article-三大原則/readme.md)
25-
- [4. Redux 組成與資料流](Redux-advance/04-article-組成與資料流/readme.md)
26-
- [5. React 專案整合 Redux](Redux-advance/05-article-整合Redux/readme.md)
27-
- [6. Lab: ToDoList 整合 Redux 練習](Redux-advance/06-lab-ToDoList練習整合Redux/readme.md)
28-
- [手機元件操作](手機元件操作-advance/readme.md)
29-
- [1. 位置資訊](手機元件操作-advance/01-article-Geolocation/readme.md)
30-
- [2. 位置資訊練習](手機元件操作-advance/02-lab-Geolocation/readme.md)
31-
- [3. 相機相簿權限](手機元件操作-advance/03-article-Camera/readme.md)
32-
- [4. Lab: ToDoList 相機相簿練習](手機元件操作-advance/04-lab-Camera/readme.md)
33-
- [動畫及手勢操作](動畫及手勢操作-advance/readme.md)
34-
- [1. 動畫介紹](動畫及手勢操作-advance/01-article-動畫介紹/readme.md)
35-
- [2. 動畫元件](動畫及手勢操作-advance/02-article-動畫元件/readme.md)
36-
- [3. 動畫樣式](動畫及手勢操作-advance/03-article-動畫樣式/readme.md)
37-
- [4. 動畫函數](動畫及手勢操作-advance/04-article-動畫函數/readme.md)
38-
- [5. 組合動畫](動畫及手勢操作-advance/05-article-組合動畫/readme.md)
39-
- [6. 手勢事件](動畫及手勢操作-advance/06-article-手勢事件/readme.md)
40-
- [7. 更新動畫值](動畫及手勢操作-advance/07-article-更新動畫值/readme.md)
41-
- [8. Lab: 滑動動畫練習](動畫及手勢操作-advance/08-lab-滑動動畫練習/readme.md)
42-
- [推播通知](推播訊息-advance/readme.md)
43-
- [1. 推播介紹](推播訊息-advance/01-article-推播介紹/readme.md)
44-
- [2. firebase 設定](推播訊息-advance/02-article-firebase設定/readme.md)
45-
- [3. iOS 套件整合](推播訊息-advance/03-article-iOS套件整合/readme.md)
46-
- [4. Android 套件整合](推播訊息-advance/04-article-Android套件整合/readme.md)
47-
- [5. 接收推播](推播訊息-advance/05-article-接收推播/readme.md)
48-
- [6. Lab: 接收推播練習](推播訊息-advance/06-lab-接收推播練習/readme.md)
49-
- [多媒體操作](多媒體操作-advance/readme.md)
50-
- [1. 音檔錄製](多媒體操作-advance/01-article-音檔錄製/readme.md)
51-
- [2. 音檔播放](多媒體操作-advance/02-article-音檔播放/readme.md)
52-
- [3. Lab: 音檔播放練習](多媒體操作-advance/03-lab-音檔播放練習/readme.md)
53-
- [4. 影片檔錄製](多媒體操作-advance/04-article-影片檔錄製/readme.md)
54-
- [5. 影片檔播放](多媒體操作-advance/05-article-影片檔播放/readme.md)
55-
- [6. Lab: 影片錄製播放練習](多媒體操作-advance/06-lab-影片錄製播放練習/readme.md)
56-
- [熱部署 Hot Deploy](HotDeploy/readme.md)
57-
- [1. CodePush 介紹](HotDeploy/CodePush.md)
58-
- [2. Lab: 熱部署更新](HotDeploy/todolist-codepush.md)
34+
- [網路環境設定](Network/setup.md)
35+
- [fetch HTTP request](Network/fetch.md)
36+
- [ToDo List RESTful API 練習](ToDoList/restful-api.md)
37+
- [第三方套件管理](third-party/index.md)
38+
- [JavaScript 套件管理方式](third-party/js-module.md)
39+
- [原生模組整合設定](third-party/native-module.md)
40+
- [整合套件練習](ToDoList/add-icon.md)
41+
- [多畫面管理 Navigation](navigation/readme.md)
42+
- [介紹管理套件 RNRF](navigation/index.md)
43+
- [ToDoList 畫面管理練習](ToDoList/router.md)
44+
- [Tab 使用方式](navigation/tabs.md)
45+
- [Drawer 使用方式](navigation/drawer.md)
46+
- [儲存空間 AsyncStorage](async-storage/index.md)
47+
- [AsyncStorage 介紹](async-storage/index.md)
48+
- [ToDo List 使用 AsyncStorage 練習](ToDoList/async-storage.md)
49+
- [生成 App 安裝檔](release/readme.md)
50+
- [打包 JS](release/index.md)
51+
- [編譯專案產生 App 安裝檔](release/generate-app.md)

ToDoList/add-icon.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# 整合套件練習
22

3+
## 下載專案
4+
5+
- ToDoList React Native Sample
6+
7+
```bash
8+
cd ~/workspace
9+
git clone https://github.com/agileworks-tw/RN_Todo_Sample
10+
cd RN_Todo_Sample
11+
yarn
12+
```
13+
314
## 練習目標
415

516
> 切換到 `feature/todo-list-with-api-server` branch

ToDoList/restful-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ adb reverse tcp:3000 tcp:3000
7272

7373
### API 規格
7474

75-
- get `/api/users/ReactNative/tasks`
75+
- get `/api/users/ReactNative/tasks`
7676

7777
```text
7878
method: 'get'

navigation/drawer.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@
22

33
## Drawer (`<Drawer>` or `<Scene drawer>`)
44

5-
Can use all `prop` as listed in `Scene` as `<Drawer>`, syntatic sugar for `<Scene drawer={true}>`
6-
75
| Property | Type | Default | Description |
86
| ------------------ | ----------------- | ------- | ---------------------------------------------------------------------------------------------------------- |
97
| `drawerImage` | `Image` | | Image to substitute drawer 'hamburger' icon, you have to set it together with `drawer` prop |
108
| `drawerIcon` | `React.Component` | | Arbitrary component to be used for drawer 'hamburger' icon, you have to set it together with `drawer` prop |
119
| `hideDrawerButton` | `boolean` | `false` | Boolean to show or not the drawerImage or drawerIcon |
1210
| `drawerPosition` | `string` | `left` | Determines whether the drawer is on the right or the left. Keywords accepted are `right` and `left` |
1311
| `drawerWidth` | `number` | | The width, in pixels, of the drawer (optional) |
12+
| `contentComponent` | `React.Component` | | Component used to render the content of the drawer (e.g. navigation items). |
1413

1514
## 使用方法
1615

1716
```js
1817
import { Drawer, Scene } from 'react-native-router-flux';
1918
...
20-
<Drawer>
19+
<Drawer drawerIcon={DrawerIcon} contentComponent={DrawerContent}>
2120
<Scene />
2221
<Scene />
2322
<Scene />

navigation/index.md

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
$ yarn add react-native-router-flux
1414
```
1515

16-
## 範例專案
17-
18-
[Example Project](https://github.com/agileworks-tw/RNRF-examples)
19-
2016
## Route 管理概念
2117

2218
### Router Stack
@@ -31,23 +27,23 @@ $ yarn add react-native-router-flux
3127
2. 定義 Router
3228
宣告 Scene 對應的 Component
3329

34-
```javascript
35-
import { Router, Stack, Scene } from 'react-native-router-flux';
36-
/* render */
37-
<Router>
38-
<Stack key="root">
39-
<Scene key="login" component={Login} title="Login" />
40-
<Scene key="register" component={Register} title="Register" />
41-
<Scene key="home" component={Home} />
42-
</Stack>
43-
</Router>;
44-
```
30+
```javascript
31+
import { Router, Stack, Scene } from 'react-native-router-flux';
32+
/* render */
33+
<Router>
34+
<Stack key="root">
35+
<Scene key="login" component={Login} title="Login" />
36+
<Scene key="register" component={Register} title="Register" />
37+
<Scene key="home" component={Home} />
38+
</Stack>
39+
</Router>;
40+
```
4541

4642
3. 使用 Actions 處理畫面跳轉
4743

48-
```javascript
49-
Actions.sceneKey();
50-
```
44+
```javascript
45+
Actions.sceneKey();
46+
```
5147

5248
### API
5349

@@ -64,4 +60,5 @@ const paramData = {
6460
// place data here
6561
};
6662
Actions.anotherPage(paramData);
63+
Actions.anotherPage({ propName: 'propValue' });
6764
```

navigation/tabs.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
## Tabs (`<Tabs>` or `<Scene tabs>`)
44

5-
Can use all `props` listed above in `<Scene>` as `<Tabs>` is syntatic sugar for `<Scene tabs={true}>`.
65

76
| Property | Type | Default | Description |
87
| ------------------------- | ----------------- | ------- | ------------------------------------------------------------------------------- |
@@ -26,7 +25,6 @@ Can use all `props` listed above in `<Scene>` as `<Tabs>` is syntatic sugar for
2625

2726
## Tab Scene (child `<Scene>` within `Tabs`)
2827

29-
A `Scene` that is a direct child of `Tabs` and can use all `props` listed above in `Scene`,
3028

3129
| Property | Type | Default | Description |
3230
| ------------- | ----------- | ----------- | ----------------------------------------------- |
@@ -39,8 +37,17 @@ A `Scene` that is a direct child of `Tabs` and can use all `props` listed above
3937
import { Tabs, Tab } from 'react-native-router-flux';
4038
...
4139
<Tabs>
42-
<Tab />
43-
<Tab />
44-
<Tab />
40+
<Tab icon={TabIcon} title="tab1"/>
41+
<Tab icon={TabIcon} title="tab2"/>
42+
<Tab icon={TabIcon} title="tab3"/>
4543
</Tabs>
4644
```
45+
46+
`TabIcon`
47+
48+
```js
49+
const TabIcon = props =>
50+
<Text style={{ color: props.focused ? 'red' : 'black' }}>
51+
{props.title}
52+
</Text>;
53+
```

react/Lifecycle.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
```js
2929
class Example extends React.Component {
30-
componentDidMount(prevProps, prevState) {
30+
componentDidMount() {
3131
// ...
3232
}
3333
}
@@ -38,17 +38,20 @@ class Example extends React.Component {
3838
## componentDidUpdate
3939

4040
> 不能在沒有條件下進行 setState,否則會無窮迴圈
41-
> 一般會透過新舊比較 ( prevProps 與 this.props ) 或是 ( this.props 與 nextProps ),state 比較亦同
42-
> 再更新 state
41+
> 一般會透過新舊比較 ( prevProps 與 this.props ) 或是 ( this.props 與 nextProps ),state 比較異同,再更新 state
4342
4443
```js
4544
class Example extends React.Component {
46-
componentDidUpdate(prevProps, prevState) {
47-
// ...
45+
componentDidUpdate(prevProps) {
46+
// Typical usage (don't forget to compare props):
47+
if (this.props.userID !== prevProps.userID) {
48+
this.fetchData(this.props.userID);
49+
}
4850
}
4951
}
5052
```
5153

54+
5255
## get­Derived­State­From­Props(nextProps, prevState)
5356

5457
get­Derived­State­From­Props 主要是對比到原先的 componentWillReceiveProps,可以透過回傳一個 object 來更新 state,如果不更新就必須回傳 null。

release/generate-app.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ MYAPP_RELEASE_KEY_PASSWORD=*****
2727

2828
### 3. Adding signing config to your app's gradle config
2929

30-
編輯 `android/app/build.gradle`
30+
編輯 `android/app/build.gradle`
3131

3232
```gradle
3333
...

release/index.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,49 @@
1212
### iOS
1313

1414
```bash
15-
react-native bundle --entry-file index.ios.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios
15+
react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios
1616
```
1717

1818
### android
1919

2020
```bash
21-
react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
21+
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
2222
```
23+
24+
## 打包問題
25+
26+
### React Native 0.60 Android Duplicate resources Error occurred when generate release apk
27+
28+
若有重新安裝 react-native 需要重做
29+
```js
30+
// file path: node_modules/react-native/react-gradle
31+
32+
doFirst {
33+
...
34+
}
35+
/** Add doLast */
36+
doLast {
37+
def moveFunc = { resSuffix ->
38+
File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");
39+
if (originalDir.exists()) {
40+
File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
41+
ant.move(file: originalDir, tofile: destDir);
42+
}
43+
}
44+
45+
moveFunc.curry("ldpi").call()
46+
moveFunc.curry("mdpi").call()
47+
moveFunc.curry("hdpi").call()
48+
moveFunc.curry("xhdpi").call()
49+
moveFunc.curry("xxhdpi").call()
50+
moveFunc.curry("xxxhdpi").call()
51+
52+
File originalDir = file("$buildDir/generated/res/react/release/raw");
53+
if (originalDir.exists()) {
54+
File destDir = file("$buildDir/../src/main/res/raw");
55+
ant.move(file: originalDir, tofile: destDir);
56+
}
57+
}
58+
```
59+
60+
相關 issue 連結: [https://github.com/facebook/react-native/issues/22234](https://github.com/facebook/react-native/issues/22234)

0 commit comments

Comments
 (0)