From 53d847de627d87d602390ec41ae0d2a018046899 Mon Sep 17 00:00:00 2001 From: sunnylqm Date: Sun, 28 Jun 2026 19:01:53 +0800 Subject: [PATCH] docs(cndocs): remove React.useState/useRef prefix in new-architecture docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - custom-cxx-types.md: React.useState → useState (5 occurrences) - layout-measurements.md: React.useRef → useRef (1 occurrence) Aligns with upstream React import removal pattern (React 17+ JSX transform). --- cndocs/the-new-architecture/custom-cxx-types.md | 10 +++++----- cndocs/the-new-architecture/layout-measurements.md | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cndocs/the-new-architecture/custom-cxx-types.md b/cndocs/the-new-architecture/custom-cxx-types.md index 94db3e21b3f..edc490b8070 100644 --- a/cndocs/the-new-architecture/custom-cxx-types.md +++ b/cndocs/the-new-architecture/custom-cxx-types.md @@ -173,8 +173,8 @@ First, we need to update the `App.tsx` file to use the new method from the Turbo ```diff title="App.tsx" // ... -+ const [cubicSource, setCubicSource] = React.useState('') -+ const [cubicRoot, setCubicRoot] = React.useState(0) ++ const [cubicSource, setCubicSource] = useState('') ++ const [cubicRoot, setCubicRoot] = useState(0) return ( @@ -366,9 +366,9 @@ To test the code in the app, we have to modify the `App.tsx` file. 2. Replace the body of the `App()` function with the following code: ```tsx title="App.tsx (App function body replacement)" -const [street, setStreet] = React.useState(''); -const [num, setNum] = React.useState(''); -const [isValidAddress, setIsValidAddress] = React.useState< +const [street, setStreet] = useState(''); +const [num, setNum] = useState(''); +const [isValidAddress, setIsValidAddress] = useState< boolean | null >(null); diff --git a/cndocs/the-new-architecture/layout-measurements.md b/cndocs/the-new-architecture/layout-measurements.md index cc693a99b0c..715cd42aee7 100644 --- a/cndocs/the-new-architecture/layout-measurements.md +++ b/cndocs/the-new-architecture/layout-measurements.md @@ -10,7 +10,7 @@ Typical code will look like this: ```tsx function AComponent(children) { - const targetRef = React.useRef(null) + const targetRef = useRef(null) useLayoutEffect(() => { targetRef.current?.measure((x, y, width, height, pageX, pageY) => {