From e018499ef07fad8b3dcf5a87bf121a44a74dfca8 Mon Sep 17 00:00:00 2001
From: chenwenhui133 <2984202073@qq.com>
Date: Wed, 18 Jun 2025 15:15:36 +0800
Subject: [PATCH] =?UTF-8?q?docs:=20[Issues:=20#ICG2DA]=20=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9react-native--sqlite-storage=E5=92=8Creact-native-syan?=
=?UTF-8?q?-image-picker=E7=A4=BA=E4=BE=8B=E4=BB=A3=E7=A0=81=EF=BC=8C?=
=?UTF-8?q?=E4=BF=AE=E6=94=B9redux-toolkit=E5=BA=93=E4=B8=AD=E5=B1=9E?=
=?UTF-8?q?=E6=80=A7=E7=9A=84required=E5=88=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
en/js/redux-toolkit.md | 94 ++++++++++++-------------
en/react-native-sqlite-storage.md | 67 ++++++++++--------
en/react-native-syan-image-picker.md | 79 ++++++++++++++++++---
zh-cn/js/redux-toolkit.md | 92 ++++++++++++------------
zh-cn/react-native-sqlite-storage.md | 67 ++++++++++--------
zh-cn/react-native-syan-image-picker.md | 79 ++++++++++++++++++---
6 files changed, 313 insertions(+), 165 deletions(-)
diff --git a/en/js/redux-toolkit.md b/en/js/redux-toolkit.md
index 77b4a7be..b957542a 100644
--- a/en/js/redux-toolkit.md
+++ b/en/js/redux-toolkit.md
@@ -18,7 +18,7 @@
> [!TIP] This library depends on the react-redux library. For details about how to install this library, see [react-redux documentation](./react-redux.md).
-Find the matching version information in the release address of a third-party library and download an applicable .tgz package: [redux-toolkit Releases](redux-toolkit Releases](https://github.com/reduxjs/redux-toolkit/releases).
+Find the matching version information in the release address of a third-party library and download an applicable .tgz package: [redux-toolkit Releases](https://github.com/reduxjs/redux-toolkit/releases).
@@ -164,58 +164,58 @@ This document is verified based on the following versions:
| Name | Description | Type | Required | Platform | HarmonyOS Support |
| ------------------------ | ------------------------------------------------------------ | -------- | -------- | -------- | ----------------- |
-| configureStore | Method used to create **store**. | Function | yes | All | yes |
-| reducer | Parameter of **configureStore**. | Object | yes | All | yes |
-| middleware | Parameter of **configureStore**, which is used to store the array of middleware. | Array | yes | All | yes |
-| devTools | Parameter of **configureStore**, which is used for browser debugging. | Boolean | yes | Web | no |
-| preloadedState | Parameter of **configureStore**, which is used to specify the default value of **state**. | Object | yes | All | yes |
-| enhancers | Parameter of **configureStore**, which is used to customize the enhancer array. | Array | yes | All | yes |
-| getDefaultMiddleware | Method used to obtain the default middleware list. | Function | yes | All | yes |
-| immutableCheck | Property of the object parameters in **getDefaultMiddleware**. | Boolean | yes | All | yes |
-| serializableCheck | Property of the object parameters in **getDefaultMiddleware**. | Boolean | yes | All | yes |
-| actionCreatorCheck | Property of the object parameters in **getDefaultMiddleware**. | Boolean | yes | All | yes |
-| createListenerMiddleware | Method used to create a listener for the middleware. | Function | yes | All | yes |
-| middleware | Property of **createListenerMiddleware**, which indicates the middleware list. | Array | yes | All | yes |
-| startListening | Property of **createListenerMiddleware**, which is used to start a listening. | Function | yes | All | yes |
-| stopListening | Property of **createListenerMiddleware**, which is used to stop a listening. | Function | yes | All | yes |
-| clearListeners | Property of **createListenerMiddleware**, which is used to clear all listening events. | Function | yes | All | yes |
-| addListener | Property of **createListenerMiddleware**, which is used to add a listener. | Function | yes | All | yes |
-| removeListener | Property of **createListenerMiddleware**, which is used to remove a listener. | Function | yes | All | yes |
-| clearAllListeners | Property of **createListenerMiddleware**, which is used to clear all listeners. | Function | yes | All | yes |
-| createDynamicMiddleware | Method used to create a middleware. | Function | yes | All | yes |
-| getDefaultEnhancers | Method used to obtain the default enhancers. | Function | yes | All | yes |
-| createReducer | Method used to create a reducer. | Function | yes | All | yes |
-| addCase | Method for the **createReducer** function to return the object parameters, which is used to add an action. | Function | yes | All | yes |
-| addMatcher | Method for the **createReducer** function to return the object parameters, which is used to add a matcher. | Function | yes | All | yes |
-| addDefaultCase | Method for the **createReducer** function to return the object parameters, which is used to add a default action. | Function | yes | All | yes |
-| createAction | Method used to create an action. | Function | yes | All | yes |
-| createSlice | Method used to create a slice. | Function | yes | All | yes |
-| name | Property of **createSlice**, which indicates the name of **store**. | String | yes | All | yes |
-| initialState | Property of **createSlice**, which indicates the default value of **store**. | object | yes | All | yes |
-| reducers | Property of **createSlice**, which is a **reducers** object. | Object | yes | All | yes |
-| extraReducers | Property of **createSlice**, which is an additional **reducers** object. | Object | yes | All | yes |
-| createAsyncThunk | Method used to create an asynchronous action. | Function | yes | All | yes |
-| createEntityAdapter | Method used to create an entity adapter. | Function | yes | All | yes |
-| selectId | Property of **createEntityAdapter**, which indicates a unique ID. | String | yes | All | yes |
-| sortComparer | Property of **createEntityAdapter**, which indicates the sorting method. | Function | yes | All | yes |
-| getInitialState | Property of **createEntityAdapter**, which indicates the default state. | Object | yes | All | yes |
-| combineSlices | Method used to combine two slices. | Function | yes | All | yes |
-| createSelector | Method used to create a selector. | Function | yes | All | yes |
+| configureStore | Method used to create **store**. | Function | NO | All | yes |
+| reducer | Parameter of **configureStore**. | Object | NO | All | yes |
+| middleware | Parameter of **configureStore**, which is used to store the array of middleware. | Array | NO | All | yes |
+| devTools | Parameter of **configureStore**, which is used for browser debugging. | Boolean | NO | Web | no |
+| preloadedState | Parameter of **configureStore**, which is used to specify the default value of **state**. | Object | NO | All | yes |
+| enhancers | Parameter of **configureStore**, which is used to customize the enhancer array. | Array | NO | All | yes |
+| getDefaultMiddleware | Method used to obtain the default middleware list. | Function | NO | All | yes |
+| immutableCheck | Property of the object parameters in **getDefaultMiddleware**. | Boolean | NO | All | yes |
+| serializableCheck | Property of the object parameters in **getDefaultMiddleware**. | Boolean | NO | All | yes |
+| actionCreatorCheck | Property of the object parameters in **getDefaultMiddleware**. | Boolean | NO | All | yes |
+| createListenerMiddleware | Method used to create a listener for the middleware. | Function | NO | All | yes |
+| middleware | Property of **createListenerMiddleware**, which indicates the middleware list. | Array | NO | All | yes |
+| startListening | Property of **createListenerMiddleware**, which is used to start a listening. | Function | NO | All | yes |
+| stopListening | Property of **createListenerMiddleware**, which is used to stop a listening. | Function | NO | All | yes |
+| clearListeners | Property of **createListenerMiddleware**, which is used to clear all listening events. | Function | NO | All | yes |
+| addListener | Property of **createListenerMiddleware**, which is used to add a listener. | Function | NO | All | yes |
+| removeListener | Property of **createListenerMiddleware**, which is used to remove a listener. | Function | NO | All | yes |
+| clearAllListeners | Property of **createListenerMiddleware**, which is used to clear all listeners. | Function | NO | All | yes |
+| createDynamicMiddleware | Method used to create a middleware. | Function | NO | All | yes |
+| getDefaultEnhancers | Method used to obtain the default enhancers. | Function | NO | All | yes |
+| createReducer | Method used to create a reducer. | Function | NO | All | yes |
+| addCase | Method for the **createReducer** function to return the object parameters, which is used to add an action. | Function | NO | All | yes |
+| addMatcher | Method for the **createReducer** function to return the object parameters, which is used to add a matcher. | Function | NO | All | yes |
+| addDefaultCase | Method for the **createReducer** function to return the object parameters, which is used to add a default action. | Function | NO | All | yes |
+| createAction | Method used to create an action. | Function | NO | All | yes |
+| createSlice | Method used to create a slice. | Function | NO | All | yes |
+| name | Property of **createSlice**, which indicates the name of **store**. | String | NO | All | yes |
+| initialState | Property of **createSlice**, which indicates the default value of **store**. | object | NO | All | yes |
+| reducers | Property of **createSlice**, which is a **reducers** object. | Object | NO | All | yes |
+| extraReducers | Property of **createSlice**, which is an additional **reducers** object. | Object | NO | All | yes |
+| createAsyncThunk | Method used to create an asynchronous action. | Function | NO | All | yes |
+| createEntityAdapter | Method used to create an entity adapter. | Function | NO | All | yes |
+| selectId | Property of **createEntityAdapter**, which indicates a unique ID. | String | NO | All | yes |
+| sortComparer | Property of **createEntityAdapter**, which indicates the sorting method. | Function | NO | All | yes |
+| getInitialState | Property of **createEntityAdapter**, which indicates the default state. | Object | NO | All | yes |
+| combineSlices | Method used to combine two slices. | Function | NO | All | yes |
+| createSelector | Method used to create a selector. | Function | NO | All | yes |
| | | | | | |
## Utilities
| Name | Description | Type | Required | Platform | HarmonyOS Support |
| ------------------- | --------------------------------------------------------- | -------- | -------- | -------- | ----------------- |
-| isAllOf | Checks whether all actions are passed. | Function | yes | All | yes |
-| isAnyOf | Checks whether an action is passed. | Function | yes | All | yes |
-| isAsyncThunkAction | Checks whether an action is asynchronous. | Function | yes | All | yes |
-| isPending | Checks whether an action is pending. | Function | yes | All | yes |
-| isRejected | Checks whether an action is fulfilled. | Function | yes | All | yes |
-| isFulfilled | Checks whether an action is rejected. | Function | yes | All | yes |
-| isRejectedWithValue | Checks whether an action is rejected with a return value. | Function | yes | All | yes |
-| nanoid | Method used to generate a random string. | Function | yes | All | yes |
-| miniSerializeError | Method used to display error information. | Function | yes | All | yes |
+| isAllOf | Checks whether all actions are passed. | Function | NO | All | yes |
+| isAnyOf | Checks whether an action is passed. | Function | NO | All | yes |
+| isAsyncThunkAction | Checks whether an action is asynchronous. | Function | NO | All | yes |
+| isPending | Checks whether an action is pending. | Function | NO | All | yes |
+| isRejected | Checks whether an action is fulfilled. | Function | NO | All | yes |
+| isFulfilled | Checks whether an action is rejected. | Function | NO | All | yes |
+| isRejectedWithValue | Checks whether an action is rejected with a return value. | Function | NO | All | yes |
+| nanoid | Method used to generate a random string. | Function | NO | All | yes |
+| miniSerializeError | Method used to display error information. | Function | NO | All | yes |
## Known Issues
diff --git a/en/react-native-sqlite-storage.md b/en/react-native-sqlite-storage.md
index db3e1148..73859e53 100644
--- a/en/react-native-sqlite-storage.md
+++ b/en/react-native-sqlite-storage.md
@@ -55,23 +55,44 @@ const database_name = 'Test.db';
const database_version = '1.0';
const database_displayname = 'SQLite Test Database';
const database_size = 200000;
-let db;
-const Item = ({title}) => (
-
- {title}
-
-);
-class SQLiteDemo extends Component {
- constructor() {
- super();
+let db: any;
+const Item = (props: any) => {
+ const { title } = props;
+ return(
+
+ {title}
+
+ )
+};
+
+interface SQLiteDemo {
+ progress: string[]
+}
+
+interface State {
+ progress: string[]
+}
+
+interface rowsType {
+ item: any,
+ length: number
+}
+
+interface ResultType {
+ rows: rowsType
+}
+
+class SQLiteDemo extends Component<{}, State> {
+ constructor(props: any) {
+ super(props);
this.progress = [];
this.state = {
progress: [],
};
}
- updateProgress = (text, resetState) => {
- let progress = [];
+ updateProgress = (text: string, resetState?: boolean) => {
+ let progress: string[] = [];
if (!resetState) {
progress = [...this.progress];
}
@@ -86,7 +107,7 @@ class SQLiteDemo extends Component {
this.closeDatabase();
};
- errorCB = err => {
+ errorCB = (err: any) => {
console.log('error: ', err);
this.updateProgress('Error: ' + (err.message || err));
return false;
@@ -110,7 +131,7 @@ class SQLiteDemo extends Component {
};
// eslint-disable-next-line no-shadow
- populateDatabase = db => {
+ populateDatabase = (db: any) => {
this.updateProgress('Database integrity check');
db.executeSql(
'SELECT 1 FROM Version LIMIT 1',
@@ -121,7 +142,7 @@ class SQLiteDemo extends Component {
this.updateProgress('Processing completed');
});
},
- error => {
+ (error: any) => {
console.log('received version error:', error);
this.updateProgress('Database not yet ready ... populating data');
db.transaction(this.populateDB, this.errorCB, () => {
@@ -136,7 +157,7 @@ class SQLiteDemo extends Component {
);
};
- populateDB = tx => {
+ populateDB = (tx: any) => {
this.updateProgress('Executing DROP stmts');
tx.executeSql('DROP TABLE IF EXISTS Employees;');
@@ -258,7 +279,7 @@ class SQLiteDemo extends Component {
console.log('all config SQL done');
};
- queryEmployees = async tx => {
+ queryEmployees = async (tx: any) => {
console.log('Executing JSON1 queries...');
// 1. JSON_OBJECT
@@ -359,7 +380,7 @@ class SQLiteDemo extends Component {
);
};
- querySuccess = (tx, results) => {
+ querySuccess = (tx: any, results: ResultType) => {
this.updateProgress('Query completed');
var len = results.rows.length;
for (let i = 0; i < len; i++) {
@@ -419,16 +440,6 @@ class SQLiteDemo extends Component {
}
- renderProgressEntry = entry => {
- return (
-
-
- {entry}
-
-
- );
- };
-
render = () => {
return (
@@ -449,7 +460,7 @@ class SQLiteDemo extends Component {
}
- keyExtractor={item => item.i}
+ keyExtractor={(item: any )=> item.i}
/>
);
diff --git a/en/react-native-syan-image-picker.md b/en/react-native-syan-image-picker.md
index 9adcb090..654a9a7e 100644
--- a/en/react-native-syan-image-picker.md
+++ b/en/react-native-syan-image-picker.md
@@ -48,21 +48,36 @@ Create an imagePicker.js file
import React from "react";
import {
StyleSheet,
- Text,
View,
Image,
ScrollView,
- TouchableOpacity,
Dimensions,
Button
} from 'react-native';
-import SYImagePicker from "react-native-syan-image-picker";
+import RNCVideo from 'react-native-video';
+import SYImagePicker, { SelectedPhoto } from "react-native-syan-image-picker";
-export default class App extends React.Component {
- constructor(props) {
+const {width} = Dimensions.get('window');
+
+interface State {
+ photos: SelectedPhoto[]
+ video: SelectedPhoto[]
+}
+
+interface ItemType {
+ height: number,
+ original_uri: string,
+ size: number,
+ width: number,
+ uri: string,
+}
+
+export default class App extends React.Component<{}, State> {
+ constructor(props: any) {
super(props);
this.state = {
photos: [],
+ video: [],
};
}
/**
@@ -72,9 +87,9 @@ export default class App extends React.Component {
SYImagePicker.showImagePicker(
{
isCamera: true,
- imageCount: 1,
+ imageCount: 1, // Cropping can be enabled only when **imageCount** is set to **1**.
quality: 10,
- compress: true,
+ compress: true, // Enable compression.
enableBase64: true,
isCrop: true,
}, (err, photos) => {
@@ -231,8 +246,10 @@ export default class App extends React.Component {
};
render() {
+ const { photos } = this.state;
+ const { video } = this.state;
return (
-
+
)
}
}
+
+const styles = StyleSheet.create({
+ scroll: {
+ padding: 5,
+ flexWrap: 'wrap',
+ flexDirection: 'row',
+ },
+ image: {
+ margin: 10,
+ width: (width - 80) / 3,
+ height: (width - 80) / 3,
+ backgroundColor: '#F0F0F0',
+ },
+ video: {
+ margin: 10,
+ width: (width - 80) / 3,
+ height: (width - 80) / 4,
+ }
+});
+
```
## Use Codegen
diff --git a/zh-cn/js/redux-toolkit.md b/zh-cn/js/redux-toolkit.md
index df06b26c..97aaf379 100644
--- a/zh-cn/js/redux-toolkit.md
+++ b/zh-cn/js/redux-toolkit.md
@@ -165,57 +165,57 @@ export function Counter() {
| Name | Description | Type | Required | Platform | HarmonyOS Support |
| ------------------------ | ------------------------------------------------- | -------- | -------- | -------- | ----------------- |
-| configureStore | 创建store的方法 | Function | yes | All | yes |
-| reducer | configureStore参数,reducer对象 | Object | yes | All | yes |
-| middleware | configureStore参数,存放中间件的数组 | Array | yes | All | yes |
-| devTools | configureStore参数,浏览器调试用具 | Boolean | yes | Web | no |
-| preloadedState | configureStore参数,默认的state值 | Object | yes | All | yes |
-| enhancers | configureStore参数,存放增强功能数组 | Array | yes | All | yes |
-| getDefaultMiddleware | 获取默认中间件列表 | Function | yes | All | yes |
-| immutableCheck | getDefaultMiddleware对象参数属性 | Boolean | yes | All | yes |
-| serializableCheck | getDefaultMiddleware对象参数属性 | Boolean | yes | All | yes |
-| actionCreatorCheck | getDefaultMiddleware对象参数属性 | Boolean | yes | All | yes |
-| createListenerMiddleware | 创建中间件监听函数 | Function | yes | All | yes |
-| middleware | createListenerMiddleware属性,中间件列表 | Array | yes | All | yes |
-| startListening | createListenerMiddleware属性,添加一个监听 | Function | yes | All | yes |
-| stopListening | createListenerMiddleware属性,暂停一个监听 | Function | yes | All | yes |
-| clearListeners | createListenerMiddleware属性,清除所有监听 | Function | yes | All | yes |
-| addListener | createListenerMiddleware属性,添加一个监听 | Function | yes | All | yes |
-| removeListener | createListenerMiddleware属性,暂停一个监听 | Function | yes | All | yes |
-| clearAllListeners | createListenerMiddleware属性,清除所有监听 | Function | yes | All | yes |
-| createDynamicMiddleware | 创建一个中间件 | Function | yes | All | yes |
-| getDefaultEnhancers | 获取默认增强功能组件 | Function | yes | All | yes |
-| createReducer | 创建reducer | Function | yes | All | yes |
-| addCase | createReducer函数返回对象参数方法,添加action | Function | yes | All | yes |
-| addMatcher | createReducer函数返回对象参数方法,添加过滤条件 | Function | yes | All | yes |
-| addDefaultCase | createReducer函数返回对象参数方法,添加默认action | Function | yes | All | yes |
-| createAction | 创建action | Function | yes | All | yes |
-| createSlice | 创建slice切片 | Function | yes | All | yes |
-| name | createSlice属性,store名字 | String | yes | All | yes |
-| initialState | createSlice属性,store默认值 | object | yes | All | yes |
-| reducers | createSlice属性,reducer对象 | Object | yes | All | yes |
-| extraReducers | createSlice属性,额外的reducer对象 | Object | yes | All | yes |
-| createAsyncThunk | 创建异步action | Function | yes | All | yes |
-| createEntityAdapter | 创建适配器 | Function | yes | All | yes |
-| selectId | createEntityAdapter属性,表示唯一ID | String | yes | All | yes |
-| sortComparer | createEntityAdapter属性,排序方法 | Function | yes | All | yes |
-| getInitialState | createEntityAdapter属性,默认状态 | Object | yes | All | yes |
-| combineSlices | 结合两个Slice切片 | Function | yes | All | yes |
-| createSelector | 创建select选择器 | Function | yes | All | yes |
+| configureStore | 创建store的方法 | Function | NO | All | yes |
+| reducer | configureStore参数,reducer对象 | Object | NO | All | yes |
+| middleware | configureStore参数,存放中间件的数组 | Array | NO | All | yes |
+| devTools | configureStore参数,浏览器调试用具 | Boolean | NO | Web | no |
+| preloadedState | configureStore参数,默认的state值 | Object | NO | All | yes |
+| enhancers | configureStore参数,存放增强功能数组 | Array | NO | All | yes |
+| getDefaultMiddleware | 获取默认中间件列表 | Function | NO | All | yes |
+| immutableCheck | getDefaultMiddleware对象参数属性 | Boolean | NO | All | yes |
+| serializableCheck | getDefaultMiddleware对象参数属性 | Boolean | NO | All | yes |
+| actionCreatorCheck | getDefaultMiddleware对象参数属性 | Boolean | NO | All | yes |
+| createListenerMiddleware | 创建中间件监听函数 | Function | NO | All | yes |
+| middleware | createListenerMiddleware属性,中间件列表 | Array | NO | All | yes |
+| startListening | createListenerMiddleware属性,添加一个监听 | Function | NO | All | yes |
+| stopListening | createListenerMiddleware属性,暂停一个监听 | Function | NO | All | yes |
+| clearListeners | createListenerMiddleware属性,清除所有监听 | Function | NO | All | yes |
+| addListener | createListenerMiddleware属性,添加一个监听 | Function | NO | All | yes |
+| removeListener | createListenerMiddleware属性,暂停一个监听 | Function | NO | All | yes |
+| clearAllListeners | createListenerMiddleware属性,清除所有监听 | Function | NO | All | yes |
+| createDynamicMiddleware | 创建一个中间件 | Function | NO | All | yes |
+| getDefaultEnhancers | 获取默认增强功能组件 | Function | NO | All | yes |
+| createReducer | 创建reducer | Function | NO | All | yes |
+| addCase | createReducer函数返回对象参数方法,添加action | Function | NO | All | yes |
+| addMatcher | createReducer函数返回对象参数方法,添加过滤条件 | Function | NO | All | yes |
+| addDefaultCase | createReducer函数返回对象参数方法,添加默认action | Function | NO | All | yes |
+| createAction | 创建action | Function | NO | All | yes |
+| createSlice | 创建slice切片 | Function | NO | All | yes |
+| name | createSlice属性,store名字 | String | NO | All | yes |
+| initialState | createSlice属性,store默认值 | object | NO | All | yes |
+| reducers | createSlice属性,reducer对象 | Object | NO | All | yes |
+| extraReducers | createSlice属性,额外的reducer对象 | Object | NO | All | yes |
+| createAsyncThunk | 创建异步action | Function | NO | All | yes |
+| createEntityAdapter | 创建适配器 | Function | NO | All | yes |
+| selectId | createEntityAdapter属性,表示唯一ID | String | NO | All | yes |
+| sortComparer | createEntityAdapter属性,排序方法 | Function | NO | All | yes |
+| getInitialState | createEntityAdapter属性,默认状态 | Object | NO | All | yes |
+| combineSlices | 结合两个Slice切片 | Function | NO | All | yes |
+| createSelector | 创建select选择器 | Function | NO | All | yes |
## 工具方法
| Name | Description | Type | Required | Platform | HarmonyOS Support |
| ------------------- | ------------------------------ | -------- | -------- | -------- | ----------------- |
-| isAllOf | 判断action是否全部通过 | Function | yes | All | yes |
-| isAnyOf | 判断action是否有一个通过 | Function | yes | All | yes |
-| isAsyncThunkAction | 判断action是否是异步 | Function | yes | All | yes |
-| isPending | 判断action是否在执行中 | Function | yes | All | yes |
-| isRejected | 判断action是否执行失败 | Function | yes | All | yes |
-| isFulfilled | 判断action是否执行完成 | Function | yes | All | yes |
-| isRejectedWithValue | 判断action是否执行失败并返回值 | Function | yes | All | yes |
-| nanoid | 生成随机字符串 | Function | yes | All | yes |
-| miniSerializeError | 打印错误信息 | Function | yes | All | yes |
+| isAllOf | 判断action是否全部通过 | Function | NO | All | yes |
+| isAnyOf | 判断action是否有一个通过 | Function | NO | All | yes |
+| isAsyncThunkAction | 判断action是否是异步 | Function | NO | All | yes |
+| isPending | 判断action是否在执行中 | Function | NO | All | yes |
+| isRejected | 判断action是否执行失败 | Function | NO | All | yes |
+| isFulfilled | 判断action是否执行完成 | Function | NO | All | yes |
+| isRejectedWithValue | 判断action是否执行失败并返回值 | Function | NO | All | yes |
+| nanoid | 生成随机字符串 | Function | NO | All | yes |
+| miniSerializeError | 打印错误信息 | Function | NO | All | yes |
## 遗留问题
diff --git a/zh-cn/react-native-sqlite-storage.md b/zh-cn/react-native-sqlite-storage.md
index 34469f25..305b2232 100644
--- a/zh-cn/react-native-sqlite-storage.md
+++ b/zh-cn/react-native-sqlite-storage.md
@@ -53,23 +53,44 @@ const database_name = 'Test.db';
const database_version = '1.0';
const database_displayname = 'SQLite Test Database';
const database_size = 200000;
-let db;
-const Item = ({title}) => (
-
- {title}
-
-);
-class SQLiteDemo extends Component {
- constructor() {
- super();
+let db: any;
+const Item = (props: any) => {
+ const { title } = props;
+ return(
+
+ {title}
+
+ )
+};
+
+interface SQLiteDemo {
+ progress: string[]
+}
+
+interface State {
+ progress: string[]
+}
+
+interface rowsType {
+ item: any,
+ length: number
+}
+
+interface ResultType {
+ rows: rowsType
+}
+
+class SQLiteDemo extends Component<{}, State> {
+ constructor(props: any) {
+ super(props);
this.progress = [];
this.state = {
progress: [],
};
}
- updateProgress = (text, resetState) => {
- let progress = [];
+ updateProgress = (text: string, resetState?: boolean) => {
+ let progress: string[] = [];
if (!resetState) {
progress = [...this.progress];
}
@@ -84,7 +105,7 @@ class SQLiteDemo extends Component {
this.closeDatabase();
};
- errorCB = err => {
+ errorCB = (err: any) => {
console.log('error: ', err);
this.updateProgress('Error: ' + (err.message || err));
return false;
@@ -108,7 +129,7 @@ class SQLiteDemo extends Component {
};
// eslint-disable-next-line no-shadow
- populateDatabase = db => {
+ populateDatabase = (db: any) => {
this.updateProgress('Database integrity check');
db.executeSql(
'SELECT 1 FROM Version LIMIT 1',
@@ -119,7 +140,7 @@ class SQLiteDemo extends Component {
this.updateProgress('Processing completed');
});
},
- error => {
+ (error: any) => {
console.log('received version error:', error);
this.updateProgress('Database not yet ready ... populating data');
db.transaction(this.populateDB, this.errorCB, () => {
@@ -134,7 +155,7 @@ class SQLiteDemo extends Component {
);
};
- populateDB = tx => {
+ populateDB = (tx: any) => {
this.updateProgress('Executing DROP stmts');
tx.executeSql('DROP TABLE IF EXISTS Employees;');
@@ -256,7 +277,7 @@ class SQLiteDemo extends Component {
console.log('all config SQL done');
};
- queryEmployees = async tx => {
+ queryEmployees = async (tx: any) => {
console.log('Executing JSON1 queries...');
// 1. JSON_OBJECT
@@ -357,7 +378,7 @@ class SQLiteDemo extends Component {
);
};
- querySuccess = (tx, results) => {
+ querySuccess = (tx: any, results: ResultType) => {
this.updateProgress('Query completed');
var len = results.rows.length;
for (let i = 0; i < len; i++) {
@@ -417,16 +438,6 @@ class SQLiteDemo extends Component {
}
- renderProgressEntry = entry => {
- return (
-
-
- {entry}
-
-
- );
- };
-
render = () => {
return (
@@ -447,7 +458,7 @@ class SQLiteDemo extends Component {
}
- keyExtractor={item => item.i}
+ keyExtractor={(item: any )=> item.i}
/>
);
diff --git a/zh-cn/react-native-syan-image-picker.md b/zh-cn/react-native-syan-image-picker.md
index 64586b6d..5a89695d 100644
--- a/zh-cn/react-native-syan-image-picker.md
+++ b/zh-cn/react-native-syan-image-picker.md
@@ -46,21 +46,36 @@ yarn add @react-native-oh-tpl/react-native-syan-image-picker
import React from "react";
import {
StyleSheet,
- Text,
View,
Image,
ScrollView,
- TouchableOpacity,
Dimensions,
Button
} from 'react-native';
-import SYImagePicker from "react-native-syan-image-picker";
+import RNCVideo from 'react-native-video';
+import SYImagePicker, { SelectedPhoto } from "react-native-syan-image-picker";
-export default class App extends React.Component {
- constructor(props) {
+const {width} = Dimensions.get('window');
+
+interface State {
+ photos: SelectedPhoto[]
+ video: SelectedPhoto[]
+}
+
+interface ItemType {
+ height: number,
+ original_uri: string,
+ size: number,
+ width: number,
+ uri: string,
+}
+
+export default class App extends React.Component<{}, State> {
+ constructor(props: any) {
super(props);
this.state = {
photos: [],
+ video: [],
};
}
/**
@@ -70,9 +85,9 @@ export default class App extends React.Component {
SYImagePicker.showImagePicker(
{
isCamera: true,
- imageCount: 1,
+ imageCount: 1, // imageCount为1才支持裁剪
quality: 10,
- compress: true,
+ compress: true, // 开启压缩
enableBase64: true,
isCrop: true,
}, (err, photos) => {
@@ -229,8 +244,10 @@ export default class App extends React.Component {
};
render() {
+ const { photos } = this.state;
+ const { video } = this.state;
return (
-
+
@@ -238,10 +255,56 @@ export default class App extends React.Component {
+
+ {video.map((item: ItemType, index: number) => {
+ const videoSource = {
+ uri: item.uri, isNetwork: false
+ };
+ return (
+
+
+ );
+ })}
+
+ {photos.map((item: ItemType, index: number) => {
+ let source = {uri: item.original_uri};
+ return (
+
+ );
+ })
+ }
+
)
}
}
+
+const styles = StyleSheet.create({
+ scroll: {
+ padding: 5,
+ flexWrap: 'wrap',
+ flexDirection: 'row',
+ },
+ image: {
+ margin: 10,
+ width: (width - 80) / 3,
+ height: (width - 80) / 3,
+ backgroundColor: '#F0F0F0',
+ },
+ video: {
+ margin: 10,
+ width: (width - 80) / 3,
+ height: (width - 80) / 4,
+ }
+});
+
```
## 使用 Codegen
--
Gitee