Function components have props
object which contains values passed to the component via props/attributes, and they don't have render
or lifecycle methods.
This is the reason why they are called "functional stateless components".
Function components return
a JSX string.
Class components have state
and props
.
Class components have render()
method which renders the JSX.
The state
is an object defined inside of the React class
component.
React class
components have React's built-in method setState()
we must use to update the state
.
React's built-in setState()
method triggers re-rendering of the DOM when state is changed.
Only the class
component itself can define the state
(object) or change it's existing state
through this.setState()
.