Please enable JavaScript.
Coggle requires JavaScript to display documents.
REACT (State (Using State Correctly (To update the satte use setState()…
REACT
State
-
-
-
-
The Data Flows Down
Neither parent nor child components can know if a certain component is stateful or stateless, and they shouldn't care whether it is defined as a function or a class
-
-
state is always owned by specific component, any data or UI derived from that state can only affect components "below" them in the tree
If you imagine a component tree as a waterfall of props, each component's state is like an additional water source that joins it at an arbitrary point but also flows down
-
-
Classes
Create an ES6 class with the same name that extends React.Component.
Add a single empty method to it called render().
Move the body of the function into the render() method.
Replace props with this.props in the render() body.
-
-
-
-