From 8b51f17bfa6f16f4be9d6755517c3158fed4f01d Mon Sep 17 00:00:00 2001 From: luozhu20 Date: Thu, 29 Jan 2026 14:17:06 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E4=BF=AE=E6=94=B9react-native-screen-c?= =?UTF-8?q?apture=E6=96=87=E6=A1=A3=E4=B8=AD=E7=A4=BA=E4=BE=8B=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=9A=84=E4=BD=BF=E7=94=A8=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: luozhu20 --- en/react-native-screen-capture.md | 17 ++++++++++------- zh-cn/react-native-screen-capture.md | 15 ++++++++++----- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/en/react-native-screen-capture.md b/en/react-native-screen-capture.md index 0e0f6589..c410fd8a 100644 --- a/en/react-native-screen-capture.md +++ b/en/react-native-screen-capture.md @@ -47,8 +47,8 @@ The following code shows the basic use scenario of the repository: > [!WARNING] The name of the imported repository remains unchanged. ```js -import React, { Component, useState } from 'react'; -import { Alert, View, Button, Text } from 'react-native'; +import React from 'react'; +import { View, Button, Text, StyleSheet } from 'react-native'; import { disallowScreenshot, keepAwake } from 'react-native-screen-capture'; class AppDemo extends React.Component { @@ -118,13 +118,18 @@ export default AppDemo; First, use DevEco Studio to open the HarmonyOS project `harmony` in the project directory. -### 1.Open `entry/oh-package.json5` file and add the following dependencies: +### 1. Overrides RN SDK + +To ensure the project relies on the same version of the RN SDK, you need to add an `overrides` field in the project's root `oh-package.json5` file, specifying the RN SDK version to be used. The replacement version can be a specific version number, a semver range, or a locally available HAR package or source directory. + +For more information about the purpose of this field, please refer to the [official documentation](https://developer.huawei.com/consumer/en/doc/harmonyos-guides-V5/ide-oh-package-json5-V5#en-us_topic_0000001792256137_overrides). ```json { - ... "overrides": { - "@rnoh/react-native-openharmony": "./react_native_openharmony" + "@rnoh/react-native-openharmony": "^0.72.38" // ohpm version + // "@rnoh/react-native-openharmony" : "./react_native_openharmony.har" // a locally available HAR package + // "@rnoh/react-native-openharmony" : "./react_native_openharmony" // source code directory } } ``` @@ -133,8 +138,6 @@ First, use DevEco Studio to open the HarmonyOS project `harmony` in the project Currently, two methods are available: - - Method 1 (recommended): Use the HAR file. > [!TIP] The HAR file is stored in the `harmony` directory in the installation path of the third-party library. diff --git a/zh-cn/react-native-screen-capture.md b/zh-cn/react-native-screen-capture.md index 06268862..ffd9a454 100644 --- a/zh-cn/react-native-screen-capture.md +++ b/zh-cn/react-native-screen-capture.md @@ -45,8 +45,8 @@ yarn add @react-native-ohos/react-native-screen-capture > [!WARNING] 使用时 import 的库名不变。 ```js -import React, { Component, useState } from 'react'; -import { Alert, View, Button, Text } from 'react-native'; +import React from 'react'; +import { View, Button, Text, StyleSheet } from 'react-native'; import { disallowScreenshot, keepAwake } from 'react-native-screen-capture'; class AppDemo extends React.Component { @@ -116,13 +116,18 @@ export default AppDemo; 首先需要使用 DevEco Studio 打开项目里的 HarmonyOS 工程 `harmony`。 -### 1.在工程根目录的 `oh-package.json5` 添加 overrides字段 +### 1. Overrides RN SDK + +为了让工程依赖同一个版本的 RN SDK,需要在工程根目录的 `oh-package.json5` 添加 overrides 字段,指向工程需要使用的 RN SDK 版本。替换的版本既可以是一个具体的版本号,也可以是一个模糊版本,还可以是本地存在的 HAR 包或源码目录。 + +关于该字段的作用请阅读[官方说明](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/ide-oh-package-json5-V5#zh-cn_topic_0000001792256137_overrides): ```json { - ... "overrides": { - "@rnoh/react-native-openharmony": "./react_native_openharmony" + "@rnoh/react-native-openharmony": "^0.72.38" // ohpm 在线版本 + // "@rnoh/react-native-openharmony" : "./react_native_openharmony.har" // 指向本地 har 包的路径 + // "@rnoh/react-native-openharmony" : "./react_native_openharmony" // 指向源码路径 } } ``` -- Gitee