Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cndocs/accessibilityinfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ static prefersCrossFadeTransitions(): Promise<boolean>;

### 🗑️ `setAccessibilityFocus()`

:::warning Deprecated
:::warning[Deprecated]
建议改用 `sendAccessibilityEvent`,并将 `eventType` 设为 `focus`。
:::

Expand Down
2 changes: 1 addition & 1 deletion cndocs/backhandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Backhandler API 检测用于后退导航的硬件按钮按下情况,允许您
- **如果一个订阅返回true,**那么之前注册的订阅将不会被调用。
- **如果没有订阅返回 true 或没有注册,** 它会以编程方式调用默认后退按钮功能以退出应用程序。

:::warning 对模式用户的警告
:::warning[对模式用户的警告]
如果您的应用程序显示打开的“Modal”,则“BackHandler”将不会发布任何事件([请参阅“Modal”文档](modal#onrequestclose))。
:::

Expand Down
2 changes: 1 addition & 1 deletion cndocs/building-for-tv.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ hide_table_of_contents: true

实现电视设备支持的目的是使现有的 React Native 应用程序可以在 Apple TV 和 Android TV 上运行,而应用程序的 JavaScript 代码只需很少或无需更改。

:::警告 已弃用
:::warning[已弃用]
电视支持已移至 [React Native for TV](https://github.com/react-native-tvos/react-native-tvos#readme) 存储库。请参阅此处的**自述文件**,了解有关 Apple TV 或 Android TV 项目的信息。
:::
2 changes: 1 addition & 1 deletion cndocs/global-PerformanceEventTiming.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id: global-PerformanceEventTiming
title: PerformanceEventTiming
---

:::warning
:::warning[部分支持]
🚧 本页面仍在完善中,请参考 [MDN 文档](https://developer.mozilla.org/zh-CN/docs/Web/API/PerformanceEventTiming) 获取更多信息。
:::

Expand Down
2 changes: 1 addition & 1 deletion cndocs/global-PerformanceLongTaskTiming.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id: global-PerformanceLongTaskTiming
title: PerformanceLongTaskTiming
---

:::warning
:::warning[部分支持]
🚧 本页面仍在完善中,请参考 [MDN 文档](https://developer.mozilla.org/zh-CN/docs/Web/API/PerformanceLongTaskTiming) 获取更多信息。
:::

Expand Down
2 changes: 1 addition & 1 deletion cndocs/global-PerformanceResourceTiming.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: PerformanceResourceTiming

全局 [`PerformanceResourceTiming`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming) 类,遵循 Web 规范定义。

:::warning 部分支持
:::warning[部分支持]

React Native 仅实现了以下 `PerformanceResourceTiming` 属性:

Expand Down
14 changes: 7 additions & 7 deletions cndocs/global-intersectionobserver.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ new IntersectionObserver(callback, options?)

一个可选对象,包含以下属性:

| 名称 | 类型 | 说明 |
| -------------------- | -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `root` | [Element](element-nodes) \| null | 目标的祖先元素,其边界矩形将被视为视口。如果未指定或为 `null`,则默认为根视口。 |
| `rootMargin` | string | 计算交叉时添加到根边界框的偏移量字符串。默认为 `"0px 0px 0px 0px"`。 |
| `threshold` | number \| number[] | 一个数值或数值数组(范围 0.0 到 1.0),指定目标元素交叉面积与总边界框面积的比值。如果未设置 `rnRootThreshold`,则默认为 `[0]`。 |
| `rnRootThreshold` ⚠️ | number \| number[] | **React Native 特有。** 一个数值或数值数组(范围 0.0 到 1.0),指定交叉面积与根元素总面积的比值。 |
| 名称 | 类型 | 说明 |
| -------------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `root` | [Element](element-nodes) \| null | 目标的祖先元素,其边界矩形将被视为视口。如果未指定或为 `null`,则默认为根视口。 |
| `rootMargin` | string | 计算交叉时添加到根边界框的偏移量字符串。默认为 `"0px 0px 0px 0px"`。 |
| `threshold` | number \| number[] | 一个数值或数值数组(范围 0.0 到 1.0),指定目标元素交叉面积与总边界框面积的比值。如果未设置 `rnRootThreshold`,则默认为 `[0]`。 |
| `rnRootThreshold` ⚠️ | number \| number[] | **React Native 特有。** 一个数值或数值数组(范围 0.0 到 1.0),指定交叉面积与根元素总面积的比值。 |

## 实例属性

Expand All @@ -61,7 +61,7 @@ new IntersectionObserver(callback, options?)

### `rnRootThresholds` ⚠️

:::warning 非标准
:::warning[非标准]
这是 React Native 特有的扩展。
:::

Expand Down
2 changes: 1 addition & 1 deletion cndocs/global-intersectionobserverentry.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import CanaryAPIWarning from './\_canary-channel-api-warning.mdx';

### `rnRootIntersectionRatio` ⚠️

:::warning 非标准
:::warning[非标准]
这是 React Native 特有的扩展。
:::

Expand Down
16 changes: 8 additions & 8 deletions cndocs/global-performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ title: performance

### `rnStartupTiming` ⚠️

:::warning 非标准
:::warning[非标准]
这是 React Native 特有的扩展。
:::

Expand All @@ -33,15 +33,15 @@ get rnStartupTiming(): ReactNativeStartupTiming;

`ReactNativeStartupTiming` 接口提供以下字段:

| 名称 | 类型 | 描述 |
| ---------------------------------------- | -------------- | ---------------------------------------------- |
| `startTime` | number \| void | React Native 运行时初始化开始的时间。 |
| `executeJavaScriptBundleEntryPointStart` | number \| void | 应用 bundle 开始执行的时间。 |
| `endTime` | number \| void | React Native 运行时完全初始化完成的时间。 |
| 名称 | 类型 | 描述 |
| ---------------------------------------- | -------------- | ----------------------------------------- |
| `startTime` | number \| void | React Native 运行时初始化开始的时间。 |
| `executeJavaScriptBundleEntryPointStart` | number \| void | 应用 bundle 开始执行的时间。 |
| `endTime` | number \| void | React Native 运行时完全初始化完成的时间。 |

### `timeOrigin`

:::warning 部分支持
:::warning[部分支持]
提供的是从 UNIX 纪元到系统启动的毫秒数,而非从 UNIX 纪元到应用启动的毫秒数。
:::

Expand Down Expand Up @@ -79,7 +79,7 @@ get rnStartupTiming(): ReactNativeStartupTiming;

### `now()`

:::warning 部分支持
:::warning[部分支持]
提供的是从系统启动开始的毫秒数,而非从应用启动开始的毫秒数。
:::

Expand Down
2 changes: 1 addition & 1 deletion cndocs/integration-with-android-fragment.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import con

进入你的宿主 Activity,确保它实现了 `DefaultHardwareBackBtnHandler` 接口:

:::warning 已弃用
:::warning[已弃用]
自 API 级别 33 起,`Activity.onBackPressed()` 已被[弃用](<https://developer.android.com/reference/android/app/Activity#onBackPressed()>)。面向 API 级别 36 的 Android 16 设备将[不再调用此方法](https://developer.android.com/about/versions/16/behavior-changes-16#predictive-back),应改用 [OnBackPressedDispatcher](https://developer.android.com/reference/androidx/activity/OnBackPressedDispatcher)
:::

Expand Down
2 changes: 1 addition & 1 deletion cndocs/interactionmanager.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: 🗑️ InteractionManager

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import constants from '@site/core/TabsConstants';

:::warning 已废弃
:::warning[已废弃]
避免长时间运行的工作,改用 [`requestIdleCallback`](global-requestIdleCallback)。
:::

Expand Down
2 changes: 1 addition & 1 deletion cndocs/modal.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default App;

### 🗑️ `animated`

:::warning 已弃用
:::warning[已弃用]
请改用 [`animationType`](modal.md#animationtype) 属性。
:::

Expand Down
2 changes: 1 addition & 1 deletion cndocs/network.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ request.open('GET', 'https://mywebsite.com/endpoint/');
request.send();
```

:::warning 注意
:::warning[注意]
XMLHttpRequest 的安全模型与网页不同,因为在原生应用中没有[跨域](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing)的概念。
:::

Expand Down
2 changes: 1 addition & 1 deletion cndocs/other-debugging-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import con

## 远程 JavaScript 调试(已移除)

:::warning 重要
:::warning[重要]
远程 JavaScript 调试功能已在 React Native 0.79 版本中移除。请查看原始的[弃用公告](https://github.com/react-native-community/discussions-and-proposals/discussions/734)。

如果你使用的是较旧版本的 React Native,请查阅[对应版本的文档](/versions)。
Expand Down
2 changes: 1 addition & 1 deletion cndocs/progressbarandroid.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id: progressbarandroid
title: '🗑️ ProgressBarAndroid'
---

:::warning Deprecated
:::warning[Deprecated]
Use one of the [community packages](https://reactnative.directory/?search=progressbar) instead.
:::

Expand Down
40 changes: 20 additions & 20 deletions cndocs/pushnotificationios.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id: pushnotificationios
title: '🗑️ PushNotificationIOS'
---

:::warning 已弃用
:::warning[已弃用]
请改用[社区提供的替代方案](https://reactnative.directory/?search=notification)。
:::

Expand Down Expand Up @@ -201,9 +201,9 @@ static getDeliveredNotifications(callback: (notifications: Object[]) => void);

**参数:**

| 名称 | 类型 | 必需 | 说明 |
| -------- | -------- | ---- | ------------------------------------ |
| callback | function | 是 | 接收已送达通知数组的函数。 |
| 名称 | 类型 | 必需 | 说明 |
| -------- | -------- | ---- | -------------------------- |
| callback | function | 是 | 接收已送达通知数组的函数。 |

一个已送达的通知是包含以下字段的对象:

Expand All @@ -226,9 +226,9 @@ static removeDeliveredNotifications(identifiers: string[]);

**参数:**

| 名称 | 类型 | 必需 | 说明 |
| ----------- | ----- | ---- | -------------------- |
| identifiers | array | 是 | 通知标识符数组。 |
| 名称 | 类型 | 必需 | 说明 |
| ----------- | ----- | ---- | ---------------- |
| identifiers | array | 是 | 通知标识符数组。 |

---

Expand Down Expand Up @@ -258,9 +258,9 @@ static getApplicationIconBadgeNumber(callback: (num: number) => void);

**参数:**

| 名称 | 类型 | 必需 | 说明 |
| -------- | -------- | ---- | ------------------------------ |
| callback | function | 是 | 处理当前角标数字的函数。 |
| 名称 | 类型 | 必需 | 说明 |
| -------- | -------- | ---- | ------------------------ |
| callback | function | 是 | 处理当前角标数字的函数。 |

---

Expand Down Expand Up @@ -292,9 +292,9 @@ static getScheduledLocalNotifications(

**参数:**

| 名称 | 类型 | 必需 | 说明 |
| -------- | -------- | ---- | -------------------------------------- |
| callback | function | 是 | 处理描述本地通知的对象数组的函数。 |
| 名称 | 类型 | 必需 | 说明 |
| -------- | -------- | ---- | ---------------------------------- |
| callback | function | 是 | 处理描述本地通知的对象数组的函数。 |

---

Expand Down Expand Up @@ -340,9 +340,9 @@ static removeEventListener(

**参数:**

| 名称 | 类型 | 必需 | 说明 |
| ---- | ------ | ---- | ----------------------------------------------- |
| type | string | 是 | 事件类型。可选值参见 `addEventListener()`。 |
| 名称 | 类型 | 必需 | 说明 |
| ---- | ------ | ---- | ------------------------------------------- |
| type | string | 是 | 事件类型。可选值参见 `addEventListener()`。 |

---

Expand All @@ -364,9 +364,9 @@ static requestPermissions(permissions?: PushNotificationPermissions[]);

**参数:**

| 名称 | 类型 | 必需 | 说明 |
| ----------- | ----- | ---- | ---------------------- |
| permissions | array | 否 | alert、badge 或 sound |
| 名称 | 类型 | 必需 | 说明 |
| ----------- | ----- | ---- | --------------------- |
| permissions | array | 否 | alert、badge 或 sound |

---

Expand Down Expand Up @@ -447,7 +447,7 @@ finish(result: string);

在 JS 端完成通知处理后,调用 `finish()` 来执行原生完成处理器。调用此方法时,传入最能描述操作结果的获取结果值。可能的值列表请参见 `PushNotificationIOS.FetchResult`。

如果你使用了 `application:didReceiveRemoteNotification:fetchCompletionHandler:`,你_必须_调用此处理器,并且应尽快调用。更多详情请参阅[官方文档](https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623013-application?language=objc)。
如果你使用了 `application:didReceiveRemoteNotification:fetchCompletionHandler:`,你*必须*调用此处理器,并且应尽快调用。更多详情请参阅[官方文档](https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623013-application?language=objc)。

---

Expand Down
2 changes: 1 addition & 1 deletion cndocs/safeareaview.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id: safeareaview
title: '🗑️ SafeAreaView'
---

:::warning 已弃用
:::warning[已弃用]
请改用 [react-native-safe-area-context](https://github.com/AppAndFlow/react-native-safe-area-context)。
:::

Expand Down
27 changes: 13 additions & 14 deletions cndocs/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import con

[Async Storage](https://github.com/react-native-async-storage/async-storage) 是一个由社区维护的 React Native 模块,它提供了一个异步、未加密的键值对存储。异步存储不是在应用之间共享的:每个应用都有自己的沙盒环境,并且无法访问其他应用的数据。

| **使用Async Storage的情况** | **不推荐使用Async Storage的情况** |
| ---------------------- | -------------------------- |
| 在应用运行间持久保存非敏感数据 | 令牌存储 |
| 持久保存 Redux 状态 | 密钥 |
| 持久保存 GraphQL 状态 | |
| **使用Async Storage的情况** | **不推荐使用Async Storage的情况** |
| ------------------------------ | --------------------------------- |
| 在应用运行间持久保存非敏感数据 | 令牌存储 |
| 持久保存 Redux 状态 | 密钥 |
| 持久保存 GraphQL 状态 | |

:::note
Async Storage 是 React Native 中与 Web 的 Local Storage 类似的功能
Expand All @@ -58,11 +58,10 @@ React Native 本身没有提供任何用于安全地储存敏感数据的方式
- [expo-secure-store](https://docs.expo.dev/versions/latest/sdk/securestore/)
- [react-native-keychain](https://github.com/oblador/react-native-keychain)

:::warning Caution
:::warning[Caution]
**请注意不要无意中存储或暴露敏感信息。**这可能会意外发生,例如在redux状态中保存敏感表单数据并持久化整个状态树到Async Storage。或者将用户令牌和个人信息发送到应用程序监控服务如Sentry或Crashlytics。
:::


## 认证和深度链接(Deep Linking)

<img src="https://cdn.jsdelivr.net/gh/reactnativecn/react-native-website@gh-pages/docs/assets/d_security_deep-linking.svg" width="225" alt=" " style={{float: 'right', margin: '0 0 1em 1em'}} />
Expand All @@ -86,14 +85,14 @@ OAuth2 认证协议现在非常流行,被誉为最完整和安全的协议之

[PKCE](https://oauth.net/2/pkce/)发音为“Pixy”代表Proof of Key Code Exchange,是对OAuth 2规范的一个扩展。这涉及到增加了一层安全措施,用来验证身份验证和令牌交换请求来自同一个客户端。PKCE使用了SHA256加密哈希算法。SHA256 为任意大小的文字或者文件创建了一个独特的“签名”,但它:

* 不管输入文件的大小总是保持一致的长度
* 对同样的输入始终产生一样的结果
* 是单向的(也就是说你不可以通过它反向工程出原始输入)
- 不管输入文件的大小总是保持一致的长度
- 对同样的输入始终产生一样的结果
- 是单向的(也就是说你不可以通过它反向工程出原始输入)

现在你有这两个值:

* **code_verifier** -由客户端生成的大随机字符串
* **code_challenge** - code_verifier 的 SHA256
- **code_verifier** -由客户端生成的大随机字符串
- **code_challenge** - code_verifier 的 SHA256

在初始的 `/authorize` 请求期间,客户端还会发送它保存在内存中的 `code_verifier` 对应的 `code_challenge`。授权请求正确返回后,客户端还会发送用于生成 `code_challenge` 的 `code_verifier`。身份提供商(IDP)随后会计算 `code_challenge`,检查它是否与最初的 `/authorize` 请求中设置的值匹配,并仅在值匹配时才发送访问令牌。

Expand All @@ -117,7 +116,7 @@ React-native-app-auth 只有在您的身份提供商支持 PKCE 时才能支持

**SSL固定**是一种可以在客户端使用的技巧来避免这种攻击。它的工作原理是在开发期间将受信任的证书列表嵌入(或固定)到客户端中,以便只接受用其中一个受信任的证书签名的请求,并拒绝任何自签名的证书。

:::warning Caution
:::warning[Caution]
使用SSL固定时,您应该注意到期日期的问题。每1-2年就需要更新一次数字认证书,在数字认证书过期之后需要同时更新应用程序和服务器上的版本信息。一旦服务器上的数字认证书得到更新,则那些内嵌有旧版数字认证书的应用将无法正常工作了。
:::

Expand Down
2 changes: 1 addition & 1 deletion cndocs/statusbar.md
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ static setHidden(hidden: boolean, animation?: StatusBarAnimation);

### 🗑️ `setNetworkActivityIndicatorVisible()` <div className="label ios">iOS</div>

:::warning 已弃用
:::warning[已弃用]
iOS 13 及更高版本不再支持状态栏网络活动指示器。此方法将在未来版本中移除。
:::

Expand Down
2 changes: 1 addition & 1 deletion cndocs/stylesheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export default App;
### `setStyleAttributePreprocessor()`
:::warning 实验性功能
:::warning[实验性功能]
可能会频繁发生破坏性变更,且不一定会提前通知。整个功能都可能被删除。使用需自担风险。
:::
Expand Down
2 changes: 1 addition & 1 deletion cndocs/textinput.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ The following values work across platforms:

### 🗑️ `blurOnSubmit`

:::warning Deprecated
:::warning[Deprecated]
`submitBehavior` 现在取代了 `blurOnSubmit`,并会覆盖由 `blurOnSubmit` 定义的行为。详见 [submitBehavior](textinput#submitbehavior)。
:::

Expand Down
2 changes: 1 addition & 1 deletion cndocs/timers.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ title: 定时器

## InteractionManager

:::warning 已弃用
:::warning[已弃用]
`InteractionManager` 的行为已更改为与 `setImmediate` 相同,应该改用 `setImmediate`。
:::

Expand Down
2 changes: 1 addition & 1 deletion cndocs/transforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export default App;

### 🗑️ `decomposedMatrix`, `rotation`, `scaleX`, `scaleY`, `transformMatrix`, `translateX`, `translateY`

:::warning 已弃用
:::warning[已弃用]
请使用 [`transform`](transforms#transform) 属性代替。
:::

Expand Down
Loading