state vs props in ReactJS
stateis used to store the data that is needed by the component.
propsis used to pass the data to child component from parent component.
stateis mutable. This means,
statecan be changed.
propsis immutable. This means, child component can not change
propsare passed to child component from parent component and it is logical to change the data by the component who passed it, not the one which is receiving it.
statecan only be in stateful components ( Class components ).
propsdon't have this limitation.
In this section, we have learned about difference between
props of component in ReactJS.
In the next section, you will learn about difference between stateful component and stateless component in ReactJS.