June 2018
Intermediate to advanced
302 pages
6h 48m
English
Props and state are the input data for rendering the component. Both props and state are actually JavaScript objects, and the component is re-rendered when props or state are changing.
The props are immutable, so the component cannot change its props. The props are received from the parent component. The component can access the props through the this.props object. For example, take a look at the following component:
class Hello extends React.Component { render() { return <h1>Hello World {this.props.user}</h1>; }}
The parent component can send props to the Hello component in the following way:
<Hello user="John" />
When the Hello component is rendered, it shows the Hello World John text.
The state can be changed inside the ...
Read now
Unlock full access