I've just created a function component which contains the expression const [state, setState] = useState()
. Now that I have access to state
and setState()
, this stateful function component is very similar to a stateful class component. I'm only aware of two differences between this component and a typical class component: when referring to the state we must use state.handle
instead of this.state.handle
, and we have easy access to the Context API outside of the render
method.
Aside from the differences that I found already, is there any difference between this stateful function component and a stateful class component? Am I incorrect in my above assertion?
To refine this question just a bit, is there anything a Class Component can do that a Function Component with Hooks can't do?