How I use React’s useEffect

As if reasoning with component lifecycles in React class components wasn’t hard enough, things got even trickier with the advent of React functional components and the useEffect hook. Here’s how I ended up using them.

Photo by Ferenc Almasi on Unsplash
  1. Start with an empty dependency array. This means that your effect will only run once. Often times, this is what you want.

Of course, it’s React’s philosophy that there isn’t one way of doing things, nor is there “one blessed way” in the documentation. So, this is why the title of this post is “How I use React’s useEffect”. Buyer beware :)

Co-founder & CTO @ AgentRisk. Former infra-tech guy (storage, networks). Startup nerd. Always building cool side-projects. #LongLA