⚛ React Tips - You're misusing the React useEffect hook (probably)

If you've got any questions feel free to DM on Twitter @reillyjodonnell
Search for a command to run...

If you've got any questions feel free to DM on Twitter @reillyjodonnell
No comments yet. Be the first to comment.
Someone shared this image above. At first glance, I wasn’t sure about the perf implications — so let’s break it down from first principles :D Let’s deconstruct this monster Here’s the code: // Function to flatten React Context Providers. const flatte...

Intro Hello it’s me from the future! I originally was going to go over file based routing but pivoted to going over important SSR concepts with React / how Bun makes it easy. It’s full of struggles with hydration (mismatches), React entry points, and...

history? Serverless is EVERYWHERE and for good reason: nearly infinite scalability, physically closer to users, and pay-for-what-you-use pricing. But not without tradeoffs — vendor lock-in, (potentially) higher costs, and the infamous cold-starts. cf...

Powered by bash and AppleScript!

Sockets can only transmit binary (text.) Imagine we have this data const message = {id: '123', name: 'Reilly', message: 'Hey'} Here's the problem: we want to send this data to the ui but we have hundreds of useEffects spread throughout the codebase....

This is def one of the most common mistakes I've seen in both personal and enterprise applications.
The useEffect hook exists to sync an external system (i.e. network, DOM) to your React application. That means when you're useEffect'ing to:
1. Adjust state or props when a certain value changes (in state or props)
2. Replicate legacy class based lifecycle methods
you're just doing it wrong.
With awesome packages like TanStack Query (React Query) & SWR you don't even need a useEffect to fetch data.
If you want to learn more about useEffect check out the new beta documentation on it: https://beta.reactjs.org/learn/you-might-not-need-an-effect