Question 3 of 10Pro Only
What is a custom hook in React? Give an example of creating and using one.
Sample answer preview
A custom hook is a JavaScript function whose name starts with use and which calls other hooks. That is the whole definition; there is no special API. It is the mechanism React provides for extracting stateful logic so it can be reused across components.
custom hookuse prefixcompositionuseLocalStoragecleanuphigher-order component