Skip to content

Commit 61816a1

Browse files
authored
docs(cndocs): sync import style, code fences, and cnwebsite deps (#1035)
- document-nodes, element-nodes, text-nodes: sync React import style (import * as React → destructured imports) to match upstream react#5101 - timers: fix code fence tsx → ts to match upstream - debugging-native-code: fix code fence objective-c → objectivec to match upstream - cnwebsite/package.json: bump docusaurus-plugin-copy-page-button ^0.8.2, @types/react ^19.2.17, prettier ^3.8.4, sass 1.101.0
1 parent a0a5042 commit 61816a1

6 files changed

Lines changed: 20 additions & 20 deletions

File tree

cndocs/debugging-native-code.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ adb logcat "*:S" ReactNative:V ReactNativeJS:V YourModuleName:D
5050

5151
在原生模块中,使用 `NSLog` 添加自定义日志:
5252

53-
```objective-c
53+
```objectivec
5454
NSLog(@"YourModuleName: %@", message);
5555
```
5656

cndocs/document-nodes.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: 文档节点
66
文档节点表示完整的原生视图树。使用原生导航的应用会为每个屏幕提供单独的文档节点。不使用原生导航的应用通常会为整个应用提供单个文档(类似于 Web 上的单页应用)。
77

88
```SnackPlayer ext=js&name=Document%20instance%20example
9-
import * as React from 'react';
9+
import {useEffect, useRef} from 'react';
1010
import {Text, TextInput, View} from 'react-native';
1111
1212
function MyComponent(props) {
@@ -19,9 +19,9 @@ function MyComponent(props) {
1919
}
2020
2121
export default function AccessingDocument() {
22-
const ref = React.useRef(null);
22+
const ref = useRef(null);
2323
24-
React.useEffect(() => {
24+
useEffect(() => {
2525
// 获取屏幕中的主文本输入框并在初始加载后聚焦它。
2626
const element = ref.current;
2727
const doc = element.ownerDocument;

cndocs/element-nodes.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ title: 元素节点
88
它们通过 refs 由所有原生组件和许多内置组件提供:
99

1010
```SnackPlayer ext=js&name=Element%20instances%20example
11-
import * as React from 'react';
12-
import { View, SafeAreaView, StyleSheet, Text } from 'react-native';
11+
import {useEffect, useRef, useState} from 'react';
12+
import {View, SafeAreaView, StyleSheet, Text} from 'react-native';
1313
1414
const ViewWithRefs = () => {
15-
const ref = React.useRef(null);
16-
const [viewInfo, setViewInfo] = React.useState('');
15+
const ref = useRef(null);
16+
const [viewInfo, setViewInfo] = useState('');
1717
18-
React.useEffect(() => {
18+
useEffect(() => {
1919
// `element` 是实现此处描述的接口的对象。
2020
const element = ref.current;
2121
const rect = JSON.stringify(element.getBoundingClientRect());

cndocs/text-nodes.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ title: 文本节点
66
文本节点表示树中的原始文本内容(类似于 Web 上的 [`Text`](https://developer.mozilla.org/zh-CN/docs/Web/API/Text) 节点)。它们不能直接通过 `refs` 访问,但可以使用元素 refs 上的方法(如 [`childNodes`](https://developer.mozilla.org/zh-CN/docs/Web/API/Node/childNodes))来访问。
77

88
```SnackPlayer ext=js&name=Text%20instances%20example
9-
import * as React from 'react';
10-
import { SafeAreaView, StyleSheet, Text } from 'react-native';
9+
import {useEffect, useRef, useState} from 'react';
10+
import {SafeAreaView, StyleSheet, Text} from 'react-native';
1111
1212
const TextWithRefs = () => {
13-
const ref = React.useRef(null);
14-
const [viewInfo, setViewInfo] = React.useState('');
13+
const ref = useRef(null);
14+
const [viewInfo, setViewInfo] = useState('');
1515
16-
React.useEffect(() => {
16+
useEffect(() => {
1717
// `textElement` 是实现此处描述的接口的对象。
1818
const textElement = ref.current;
1919
const textNode = textElement.childNodes[0];

cndocs/timers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ title: 定时器
3333

3434
应用可以通过以下代码来安排一个任务,使其在交互结束之后执行:
3535

36-
```tsx
36+
```ts
3737
InteractionManager.runAfterInteractions(() => {
3838
// ...long-running synchronous task...
3939
});
@@ -49,7 +49,7 @@ InteractionManager.runAfterInteractions(() => {
4949

5050
InteractionManager 还允许应用注册动画,在动画开始时创建一个交互“句柄”,然后在结束的时候清除它。
5151

52-
```tsx
52+
```ts
5353
const handle = InteractionManager.createInteractionHandle();
5454
// run animation... (`runAfterInteractions` tasks are queued)
5555
// later, on animation completion:

cnwebsite/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"@docusaurus/plugin-pwa": "3.10.1",
5454
"@docusaurus/preset-classic": "3.10.1",
5555
"@docusaurus/theme-mermaid": "3.10.1",
56-
"docusaurus-plugin-copy-page-button": "^0.8.1",
56+
"docusaurus-plugin-copy-page-button": "^0.8.2",
5757
"docusaurus-plugin-sass": "^0.2.6",
5858
"react": "^19.2.7",
5959
"react-dom": "^19.2.7",
@@ -67,12 +67,12 @@
6767
"@react-native-website/lint-examples": "*",
6868
"@signalwire/docusaurus-plugin-llms-txt": "^1.2.2",
6969
"@types/google.analytics": "^0.0.46",
70-
"@types/react": "^19.2.16",
70+
"@types/react": "^19.2.17",
7171
"eslint": "^9.39.4",
7272
"glob": "^13.0.6",
73-
"prettier": "^3.8.3",
73+
"prettier": "^3.8.4",
7474
"remark-cli": "^12.0.1",
75-
"sass": "1.100.0",
75+
"sass": "1.101.0",
7676
"typescript": "^6.0.3"
7777
}
7878
}

0 commit comments

Comments
 (0)