diff --git a/en/react-native-screen-capture.md b/en/react-native-screen-capture.md index 0e0f658908e81090af36efdf53f532bb24d89165..c410fd8a0fe4f9fdf727161d966cb5563da270f0 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 0626886283f3d8b1612e0327ed3103c14bfcec6b..ffd9a4548f6231574bad1192115e80b1789816a7 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" // 指向源码路径 } } ```