diff --git a/zh-cn/react-native-async-storage-async-storage.md b/zh-cn/react-native-async-storage-async-storage.md
index c28b26d40a17691068eed8c86e6b06d6671163ec..98eca3d48fbd125f9deb8c24e435e6b1c7f0570d 100644
--- a/zh-cn/react-native-async-storage-async-storage.md
+++ b/zh-cn/react-native-async-storage-async-storage.md
@@ -1,5 +1,5 @@
-> 模板版本:v0.1.3
+> 模板版本:v0.2.2
@react-native-async-storage/async-storage
@@ -13,11 +13,11 @@
-> [!tip] [Github 地址](https://github.com/react-native-oh-library/async-storage)
+> [!TIP] [Github 地址](https://github.com/react-native-async-storage/async-storage)
## 安装与使用
-请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/async-storage> Releases](https://github.com/react-native-oh-library/async-storage/releases),并下载适用版本的 tgz 包。
+请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/async-storage Releases](https://github.com/react-native-oh-library/async-storage/releases),并下载适用版本的 tgz 包。
进入到工程目录并输入以下命令:
@@ -44,35 +44,60 @@ yarn add @react-native-oh-tpl/async-storage@file:#
> [!WARNING] 使用时 import 的库名不变。
```js
+import React, { useState } from 'react';
import AsyncStorage from "@react-native-async-storage/async-storage";
+import { View, Text, Button } from "react-native-harmony";
// Storing data
-const storeData = async (value) => {
- try {
- await AsyncStorage.setItem("my-key", value);
- } catch (e) {
- // saving error
- }
-};
-
-// Reading data
-const getData = async () => {
- try {
- const value = await AsyncStorage.getItem("my-key");
- if (value !== null) {
- // value previously stored
+export function AsyncDemo(): JSX.Element {
+ const [storageValue, setStorageValue] = useState("张三")
+ const storeData = async () => {
+ try {
+ await AsyncStorage.setItem("my-key", "李四");
+ } catch (e) {
+
}
- } catch (e) {
- // error reading value
- }
-};
+ };
+
+ // Reading data
+ const getData = async () => {
+ try {
+ const value = await AsyncStorage.getItem("my-key");
+
+ if (value !== null) {
+ setStorageValue(value)
+ }
+
+ } catch (e) {
+
+ }
+ };
+ return
+
+
+ {storageValue}
+
+}
```
+## 使用 Codegen(如本库已适配了 Codegen )
+本库已经适配了 Codegen ,在使用前需要主动执行生成三方库桥接代码,详细请参考[Codegen 使用文档。](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/model.md#https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/codegen.md)
+
## Link
-目前 HarmonyOS 暂不支持 AutoLink,所以 Link 步骤需要手动配置。
+目前鸿蒙暂不支持 AutoLink,所以 Link 步骤需要手动配置。
-首先需要使用 DevEco Studio 打开项目里的 HarmonyOS 工程 `harmony`
+首先需要使用 DevEco Studio 打开项目里的鸿蒙工程 `harmony`
+
+### 在工程根目录的 `oh-package.json` 添加 overrides 字段
+```json
+{
+ ...
+ "overrides": {
+ "@rnoh/react-native-openharmony" : "./react_native_openharmony"
+ }
+}
+```
### 引入原生端代码
@@ -90,8 +115,7 @@ const getData = async () => {
```json
"dependencies": {
"@rnoh/react-native-openharmony": "file:../react_native_openharmony",
-
- "rnoh-async-storage": "file:../../node_modules/@react-native-oh-tpl/async-storage/harmony/async_storage.har"
+ "@react-native-oh-tpl/async-storage": "file:../../node_modules/@react-native-oh-tpl/async-storage/harmony/async_storage.har"
}
```
@@ -116,7 +140,7 @@ ohpm install
project(rnapp)
cmake_minimum_required(VERSION 3.4.1)
set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
-set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
++ set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp")
add_subdirectory("${RNOH_CPP_DIR}" ./rn)
@@ -187,11 +211,13 @@ ohpm install
然后编译、运行即可。
-## 兼容性
+## 约束与限制
+
+### 兼容性
要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。
-请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-library/async-storage Releases](https://github.com/react-native-oh-library/async-storage/releases)
+请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[Releases](https://github.com/react-native-oh-library/async-storage/releases)
## API
@@ -223,5 +249,4 @@ ohpm install
## 开源协议
本项目基于 [The MIT License (MIT)](https://github.com/callstack/react-native-slider/blob/main/LICENSE.md) ,请自由地享受和参与开源。
-
-
\ No newline at end of file
+