-
Book Overview & Buying
-
Table Of Contents
Designing React Hooks the Right Way
By :
We have seen quite a few hooks provided by React. Let's take a moment to review what we have learned so far:
useState hook.useEffect hook.useMemo hook.useContext hook.useRef hook.The useState hook is the most popular one, which is used to define a state and make it dispatchable to trigger a UI update. React wants us to use this as the main mechanism to be in sync with the screen. A mental picture of using it is that, as long as the state changes, the UI should produce an outcome accordingly. Otherwise, the UI should stay intact. Essentially, what that is saying is to make something happen on the screen, design a state and wire it with elements. This is the React way. If you take this as a baseline, it can help you understand anything else.
The useEffect hook allows us to listen...
Change the font size
Change margin width
Change background colour