React Hook
Recall there are two ways to create React components: Function Component and Class Component.
React class components can hold state and have lifecycles. On the other hand, function components don't, unless you use React Hooks!
As part of React 16.8, the Hooks were released to make it possible to use state, and other React features with function components.
This chapter will take a deeper dive into using useState
and useEffect
Hooks. These two are bar far, the most commonly used Hooks. However, there are other Hooks built into React, and you can create your own Hooks too! Please consult the resources below.
Resources
- React Docs, Introducing Hooks.
- React Docs, Hooks API Reference.
- React Docs, Building Your Own Hooks.
- Snippets of Hooks.
- React Hooks Cheatsheet.