- We would use
this.setState()
and bind event handlers withthis.[name of the event handler]
to access the state, you would use this.state.[something]
.
-
The state variable is stored within the function component. When we want to access the state, it is already available in the scope (
const [name, setName = useState('')]
). -
useState()
is a hook, which allows you to hook into react features from within a function component.