mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-23 20:23:08 +00:00
Terminology: Lifecycle hooks -> Lifecycle methods (#1237)
This commit is contained in:
@@ -434,7 +434,7 @@ mountTree(<App />, rootEl);
|
||||
|
||||
### Unmounting
|
||||
|
||||
Now that we have internal instances that hold onto their children and the DOM nodes, we can implement unmounting. For a composite component, unmounting calls a lifecycle hook and recurses.
|
||||
Now that we have internal instances that hold onto their children and the DOM nodes, we can implement unmounting. For a composite component, unmounting calls a lifecycle method and recurses.
|
||||
|
||||
```js
|
||||
class CompositeComponent {
|
||||
@@ -442,7 +442,7 @@ class CompositeComponent {
|
||||
// ...
|
||||
|
||||
unmount() {
|
||||
// Call the lifecycle hook if necessary
|
||||
// Call the lifecycle method if necessary
|
||||
var publicInstance = this.publicInstance;
|
||||
if (publicInstance) {
|
||||
if (publicInstance.componentWillUnmount) {
|
||||
@@ -514,7 +514,7 @@ function mountTree(element, containerNode) {
|
||||
}
|
||||
```
|
||||
|
||||
Now, running `unmountTree()`, or running `mountTree()` repeatedly, removes the old tree and runs the `componentWillUnmount()` lifecycle hook on components.
|
||||
Now, running `unmountTree()`, or running `mountTree()` repeatedly, removes the old tree and runs the `componentWillUnmount()` lifecycle method on components.
|
||||
|
||||
### Updating
|
||||
|
||||
@@ -554,7 +554,7 @@ This is the part that is often described as "virtual DOM diffing" although what
|
||||
|
||||
### Updating Composite Components
|
||||
|
||||
When a composite component receives a new element, we run the `componentWillUpdate()` lifecycle hook.
|
||||
When a composite component receives a new element, we run the `componentWillUpdate()` lifecycle method.
|
||||
|
||||
Then we re-render the component with the new props, and get the next rendered element:
|
||||
|
||||
@@ -868,9 +868,9 @@ This document is simplified compared to the real codebase. There are a few impor
|
||||
|
||||
* The reconciler also takes care of attaching and detaching refs to composite components and host nodes.
|
||||
|
||||
* Lifecycle hooks that are called after the DOM is ready, such as `componentDidMount()` and `componentDidUpdate()`, get collected into "callback queues" and are executed in a single batch.
|
||||
* Lifecycle methods that are called after the DOM is ready, such as `componentDidMount()` and `componentDidUpdate()`, get collected into "callback queues" and are executed in a single batch.
|
||||
|
||||
* React puts information about the current update into an internal object called "transaction". Transactions are useful for keeping track of the queue of pending lifecycle hooks, the current DOM nesting for the warnings, and anything else that is "global" to a specific update. Transactions also ensure React "cleans everything up" after updates. For example, the transaction class provided by React DOM restores the input selection after any update.
|
||||
* React puts information about the current update into an internal object called "transaction". Transactions are useful for keeping track of the queue of pending lifecycle methods, the current DOM nesting for the warnings, and anything else that is "global" to a specific update. Transactions also ensure React "cleans everything up" after updates. For example, the transaction class provided by React DOM restores the input selection after any update.
|
||||
|
||||
### Jumping into the Code
|
||||
|
||||
|
||||
Reference in New Issue
Block a user