React useEffect for Side Effects

✨ 𝗗𝗮𝘆 𝟰 𝗼𝗳 𝗠𝘆 𝗥𝗲𝗮𝗰𝘁 𝗝𝗼𝘂𝗿𝗻𝗲𝘆 ⚛️🚀 Today I learned about the `𝘂𝘀𝗲𝗘𝗳𝗳𝗲𝗰𝘁` 𝗵𝗼𝗼𝗸, and more importantly, 𝘄𝗵𝘆 𝘄𝗲 𝗮𝗰𝘁𝘂𝗮𝗹𝗹𝘆 𝗻𝗲𝗲𝗱 𝗶𝘁. While working with React, I noticed that components are mainly for rendering UI. But sometimes we need to do things outside rendering — like fetching data, setting up timers, or updating something after the UI changes. That’s where `𝘂𝘀𝗲𝗘𝗳𝗳𝗲𝗰𝘁` comes in. It lets us handle these 𝘀𝗶𝗱𝗲 𝗲𝗳𝗳𝗲𝗰𝘁𝘀 in a clean and controlled way. What I found interesting is how it runs after render and can depend on specific values. Instead of mixing everything together, React separates 𝗨𝗜 𝗹𝗼𝗴𝗶𝗰 from 𝘀𝗶𝗱𝗲 𝗲𝗳𝗳𝗲𝗰𝘁𝘀, which makes the code easier to understand and manage. Starting to see how React keeps things structured as apps grow 💻⚡ #ReactJS #JavaScript #WebDevelopment #LearningJourney #FrontendDevelopment

  • diagram

To view or add a comment, sign in

Explore content categories