Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(cn): conditional-rendering #615

Closed

Conversation

Alienover
Copy link
Contributor

No description provided.


If you're coming from an object-oriented programming background, you might assume that the two examples above are subtly different because one of them may create two different "instances" of `<li>`. But JSX elements aren't "instances" because they don't hold any internal state and aren't real DOM nodes. They're lightweight descriptions, like blueprints. So these two examples, in fact, *are* completely equivalent. [Preserving and Resetting State](/learn/preserving-and-resetting-state) goes into detail about how this works.
如果你之前是习惯面向对象开发的,你可能会认为上面的两个例子略有不同,因为其中一个可能会创建两个不同的 `<li>` “实例”。但 JSX 元素不是“实例”,因为它们没有内部状态也不是真是的 DOM 节点。它们只是一些简单的描述,就像图纸一样。所以上面这两个例子,事实上,是完全相同的。在 [状态的保持和重置](/learn/preserving-and-resetting-state) 里会深入探讨其原因。
Copy link
Contributor Author

@Alienover Alienover Oct 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will update the Preserving and Resetting State after someone translated it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really awkward.
Feels the need to do a synchronization after the relevant chapter is completed and we'd better synchronize to the issue #611 in time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. @QC-L can we standardize the translation for each chapter title and publish them to #609


```js
if (isPacked) {
itemContent = name + " ✔";
}
```

[Curly braces open the "window into JavaScript".](/learn/javascript-in-jsx-with-curly-braces#using-curly-braces-a-window-into-the-javascript-world) Embed the variable with curly braces in the returned JSX tree, nesting the previously calculated expression inside of JSX:
[大括号 - JavaScript 的“新世界”。](/learn/javascript-in-jsx-with-curly-braces#using-curly-braces-a-window-into-the-javascript-world) 将变量用大括号嵌入在返回的 JSX 树中,来嵌套计算好的表达式与 JSX
Copy link
Contributor Author

@Alienover Alienover Oct 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will update the Curly braces open the "window" into JavaScript" after someone translated it.

@Alienover
Copy link
Contributor Author

Alienover commented Nov 3, 2021

Close and move to #636

@Alienover Alienover closed this Nov 3, 2021
@Alienover Alienover deleted the docs-cn-conditional-rendering branch November 3, 2021 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants