diff --git a/content/docs/implementation-notes.md b/content/docs/implementation-notes.md index b345f7d5d..193c5f192 100644 --- a/content/docs/implementation-notes.md +++ b/content/docs/implementation-notes.md @@ -9,93 +9,93 @@ redirect_from: - "contributing/implementation-notes.html" --- -This section is a collection of implementation notes for the [stack reconciler](/docs/codebase-overview.html#stack-reconciler). +Bài viết này bao gồm các ghi chú về việc thực thi [stack reconciler](/docs/codebase-overview.html#stack-reconciler). -It is very technical and assumes a strong understanding of React public API as well as how it's divided into core, renderers, and the reconciler. If you're not very familiar with the React codebase, read [the codebase overview](/docs/codebase-overview.html) first. +Bài viết đòi hỏi kiến thức chuyên môn cao và sự thông hiểu tốt về các public API của React cũng như cách nó được phân ra các phần cốt lõi (core), các phần render (renderer) và phần điều phối, cập nhật component (reconciler). Nếu bạn chưa nắm rõ về codebase của React, trước tiên hãy đọc [tổng quan codebase](/docs/codebase-overview.html). -It also assumes an understanding of the [differences between React components, their instances, and elements](/blog/2015/12/18/react-components-elements-and-instances.html). +Bạn cũng cần hiểu về [sự khác biệt giữa React components, các instance và phần tử (element) của chúng](/blog/2015/12/18/react-components-elements-and-instances.html) trước khi bước vào bài viết này. -The stack reconciler was used in React 15 and earlier. It is located at [src/renderers/shared/stack/reconciler](https://github.com/facebook/react/tree/15-stable/src/renderers/shared/stack/reconciler). +Stack reconciler đã được sử dụng trong React 15 và các phiên bản trước đó. Hiện thực của nó nằm ở [src/renderers/shared/stack/reconciler](https://github.com/facebook/react/tree/15-stable/src/renderers/shared/stack/reconciler). -### Video: Building React from Scratch {#video-building-react-from-scratch} +### Video: Xây dựng React từ con số không {#video-building-react-from-scratch} -[Paul O'Shannessy](https://twitter.com/zpao) gave a talk about [building React from scratch](https://www.youtube.com/watch?v=_MAD4Oly9yg) that largely inspired this document. +[Paul O'Shannessy](https://twitter.com/zpao) đã có một bài nói về việc [xây dựng React từ con số không](https://www.youtube.com/watch?v=_MAD4Oly9yg). Bài nói đó đã giúp ích rất nhiều cho bài viết này. -Both this document and his talk are simplifications of the real codebase so you might get a better understanding by getting familiar with both of them. +Cả bài nói và bài viết là cách trình bày đơn giản hóa cho codebase thật sự của React, nên bạn có thể hiểu rõ hơn về codebase nếu đi qua cả hai. -### Overview {#overview} +### Tổng quan {#overview} -The reconciler itself doesn't have a public API. [Renderers](/docs/codebase-overview.html#renderers) like React DOM and React Native use it to efficiently update the user interface according to the React components written by the user. +Bản thân reconciler không có API mở (public API). [Các phần render](/docs/codebase-overview.html#renderers) như React DOM và React Native sử dụng nó để cập nhật giao diện người dùng một cách hiệu quả theo những component mà người dùng viết. -### Mounting as a Recursive Process {#mounting-as-a-recursive-process} +### Quá trình mounting đệ quy {#mounting-as-a-recursive-process} -Let's consider the first time you mount a component: +Hãy nhìn lại lần đầu tiên chúng ta mount một component: ```js ReactDOM.render(, rootEl); ``` -React DOM will pass `` along to the reconciler. Remember that `` is a React element, that is, a description of *what* to render. You can think about it as a plain object: +React DOM sẽ đưa `` đến reconciler. Hãy nhớ rằng `` là một phần tử của React, nghĩa là, nó miêu tả *cái gì* được render. Bạn có thể xem nó như là một object thuần: ```js console.log(); // { type: App, props: {} } ``` -The reconciler will check if `App` is a class or a function. +Reconciler sẽ kiểm tra xem `App` là một lớp hay một hàm. -If `App` is a function, the reconciler will call `App(props)` to get the rendered element. +Nếu `App` là một hàm, reconciler sẽ gọi đến `App(props)` để lấy ra những phần tử được render. -If `App` is a class, the reconciler will instantiate an `App` with `new App(props)`, call the `componentWillMount()` lifecycle method, and then will call the `render()` method to get the rendered element. +Nếu `App` là một lớp, reconciler sẽ tạo ra một thực thể mới từ `App` với `new App(props)`, gọi đến hàm lifecycle `componentWillMount()`, và rồi gọi đến hàm `render()` để lấy ra những phần tử được render. -Either way, the reconciler will learn the element `App` "rendered to". +Theo hướng nào đi nữa, reconciler đều sẽ xem `App` sẽ render ra những phần tử gì. -This process is recursive. `App` may render to a ``, `Greeting` may render to a `