From cac4e07cb2296aec1a9ac4fb1406770a14bb7622 Mon Sep 17 00:00:00 2001
From: Yucohny <79147654+Yucohny@users.noreply.github.com>
Date: Fri, 20 Oct 2023 10:05:02 +0800
Subject: [PATCH] fix: resolve conflicts
---
.../learn/preserving-and-resetting-state.md | 37 +------------------
1 file changed, 2 insertions(+), 35 deletions(-)
diff --git a/src/content/learn/preserving-and-resetting-state.md b/src/content/learn/preserving-and-resetting-state.md
index f6f9fc8dc2..4abba2dd14 100644
--- a/src/content/learn/preserving-and-resetting-state.md
+++ b/src/content/learn/preserving-and-resetting-state.md
@@ -14,34 +14,6 @@ translators:
-<<<<<<< HEAD
-* React 如何“处理”组件结构
-* React 何时选择保留或重置 state
-* 如何强制 React 重置组件的 state
-* key 和组件类型如何影响 state 是否被保留
-
-
-
-## UI 树 {/*the-ui-tree*/}
-
-浏览器使用许多树形结构来为 UI 建立模型。[DOM](https://developer.mozilla.org/docs/Web/API/Document_Object_Model/Introduction) 用于表示 HTML 元素,[CSSOM](https://developer.mozilla.org/docs/Web/API/CSS_Object_Model) 则表示 CSS 元素。甚至还有 [Accessibility tree](https://developer.mozilla.org/docs/Glossary/Accessibility_tree)!
-
-React 也使用树形结构来对你创造的 UI 进行管理和建模。React 根据你的 JSX 生成 **UI 树**。React DOM 根据 UI 树去更新浏览器的 DOM 元素。(React Native 则将这些 UI 树转译成移动平台上特有的元素。)
-
-
-
-
-
-React 会根据组件创建了一棵 UI 树,React DOM 用它来渲染 DOM
-
-
-
-
-
-## state 与树中的某个位置相关联 {/*state-is-tied-to-a-position-in-the-tree*/}
-
-当你为一个组件添加 state 时,你可能会觉得 state “活”在组件内部。但实际上,state 被保存在 React 内部。根据组件在 UI 树中的位置,React 将它所持有的每个 state 与正确的组件关联起来。
-=======
* When React chooses to preserve or reset the state
* How to force React to reset component's state
* How keys and types affect whether the state is preserved
@@ -51,11 +23,10 @@ React 会根据组件创建了一棵 UI 树,React DOM 用它来渲染 DOM
## State is tied to a position in the render tree {/*state-is-tied-to-a-position-in-the-tree*/}
React builds [render trees](learn/understanding-your-ui-as-a-tree#the-render-tree) for the component structure in your UI.
->>>>>>> 9af01e2bb2c6517c3ca14b551cdfa42424370a6e
When you give a component state, you might think the state "lives" inside the component. But the state is actually held inside React. React associates each piece of state it's holding with the correct component by where that component sits in the render tree.
-下面只定义了一个 `` JSX 标签,但将它渲染在了两个不同的位置:
+Here, there is only one `` JSX tag, but it's rendered at two different positions:
@@ -207,11 +178,7 @@ Updating state
-<<<<<<< HEAD
-只有当你在相同的位置渲染相同的组件时,React 才会一直保留着组件的 state。想要验证这一点,可以将两个计数器的值递增,取消勾选 “渲染第二个计数器” 复选框,然后再次勾选它:
-=======
-React will keep the state around for as long as you render the same component at the same position in the tree. To see this, increment both counters, then remove the second component by unchecking "Render the second counter" checkbox, and then add it back by ticking it again:
->>>>>>> 9af01e2bb2c6517c3ca14b551cdfa42424370a6e
+只有当在树中相同的位置渲染相同的组件时,React 才会一直保留着组件的 state。想要验证这一点,可以将两个计数器的值递增,取消勾选 “渲染第二个计数器” 复选框,然后再次勾选它: