Please enable JavaScript.
Coggle requires JavaScript to display documents.
REACT, The Component Lifecycle, this.props.children, componentWillUnmount(…
REACT
-
-
FUNCTION COMPONENTS
Hooks
State Hook: useState()
When we call this function, it returns an array with two values:
-
-
-
-
The Component Lifecycle
- Mounting, when the component is being initialized and put into the DOM for the first time
componentDidMount()
A component “mounts” when it renders for the first time. When a component mounts, it automatically calls these three methods, in the order of:
-
-
-
- Unmounting, when the component is being removed from the DOM
- Updating, when the component updates as a result of changed state or changed props
-
-
this.props.children
-
If a component has more than one child between its JSX tags, then this.props.children will return those children in an array. However, if a component has only one child, then this.props.children will return the single child, not wrapped in an array.
-
componentWillUnmount()
In general, when a component produces a side-effect, you should remember to clean it up.
-
import React from 'react' creates a JavaScript object. This object contains properties that are needed to make React work, such as React.createElement() and React.Component.
-
import ReactDOM from 'react-dom' creates another JavaScript object. This object contains methods that help React interact with the DOM, such as ReactDOM.render().
-
By subclassing React.Component, you create a new component class. This is not a component! A component class is more like a factory that produces components. When you start making components, each one will come from a component class.
-
Whenever you create a component class, you need to give that component class a name. That name should be written in UpperCamelCase.
-