from React Beginner Tutorial useEffect() React Beginner Tutorial (6) Side Effects | Hypertext Candy
- useEffect() for running other processes according to React’s convenience
-
The callback function passed to useEffect is always executed after rendering is complete. Therefore, it is safe to reference the DOM within that callback.
- The timing can be adjusted nicely with the second argument
-
In this way, useEffect can also be used for the pattern of “I want to execute this process when this variable is updated.”
-
- It is not good to return strange things in useEffect (it should return a cleanup function)
-
- Asynchronous Processing in Javascript #React