Skip to content

Today I Learned - 2023-08-05

Posted on:August 5, 2023 at 05:33 AM

I wanted a better understanding of the commonly used React Hooks. A few days ago, I took a look at the useContext Hook. Today, I’m diving into useEffect by reading through React’s documentation on useEffect.

useEffect

  1. When do you use useEffect?
  1. What is a setup, and when does it run?
  1. When does the effect setup re-run?
  1. What could the setup function potentially return?
  1. When does the cleanup function run?
  1. What can you pass as an argument for the ‘dependencies’ parameter?
  1. What happens if you don’t pass anything to the dependencies parameter?
  1. What is something particular that happens with regards to useEffect’s setup and cleanup function when the project is in development mode? WHY?
  1. What is the general rule of reactive values if I’m using them within the Effect code?
  1. What hapepns if you pass an empty [] as a dependency list to an Effect?
  1. Why is it important to remove unnecessary object or function dependencies?

Thoughts after reading useEffect docs: