🔥 Unpopular opinion: Most React developers don’t actually understand useEffect. I didn’t either… until my app froze in production. 💥 No errors. No warnings. Just a stuck screen. The culprit? 👇 useEffect(() => { fetchData(); }); Looks normal, right? ❌ 💥 This runs on EVERY render → fetch updates state → state triggers render → infinite loop ♾️ And your app? Dead. ✅ Fix: useEffect(() => { fetchData(); }, []) 💡 Lesson: useEffect isn’t “run this code” It’s “run this code when dependencies change” Most bugs aren’t logic issues. They’re misunderstanding how React works. Follow me more Such learning Content and the mistakes that I had made, so that you shouldn't ✍️👨💻 #ReactJS #Frontend #JavaScript #SoftwareEngineering
React useEffect Gotcha: Infinite Loop and App Freeze
More Relevant Posts
-
React taught me something no tutorial ever will… Users don’t care how complex your app is. They only care if it works smoothly. They won’t see: the state you managed across 5 components the Redux logic keeping everything in sync the hours spent fixing one tiny bug the edge cases you handled silently If everything works perfectly… 👉 they notice nothing. And that’s the goal. Because in frontend, a seamless UI is just hundreds of invisible problems solved. Not gonna lie — it can feel underrated sometimes. But there’s a different kind of satisfaction in knowing: You turned messy logic into something simple for the user. That’s real development. Frontend devs — what’s something you’ve fixed that no one will ever notice? 👇 #ReactJS #Redux #FrontendDeveloper #DeveloperLife #BuildInPublic #CodingJourney #ReactJS #Redux #FrontendDevelopment #DeveloperLife #BuildInPublic #TechCareers #SoftwareDeveloper
To view or add a comment, sign in
-
🚨 𝗧𝗵𝗶𝘀 𝘀𝗺𝗮𝗹𝗹 ! 𝗶𝗻 𝗧𝘆𝗽𝗲𝗦𝗰𝗿𝗶𝗽𝘁 𝗰𝗮𝗻 𝗰𝗿𝗮𝘀𝗵 𝘆𝗼𝘂𝗿 𝗲𝗻𝘁𝗶𝗿𝗲 𝗮𝗽𝗽. 𝗬𝗲𝘀… 𝘀𝗲𝗿𝗶𝗼𝘂𝘀𝗹𝘆. I once saw code like this: user!.name At first glance, it looks harmless. But this one symbol can silently introduce runtime bugs if you don’t understand it. 💡 𝗦𝗼 𝘄𝗵𝗮𝘁 𝗱𝗼𝗲𝘀 ! 𝗮𝗰𝘁𝘂𝗮𝗹𝗹𝘆 𝗱𝗼? It’s called the 𝗡𝗼𝗻-𝗡𝘂𝗹𝗹 𝗔𝘀𝘀𝗲𝗿𝘁𝗶𝗼𝗻 𝗢𝗽𝗲𝗿𝗮𝘁𝗼𝗿 👉 It tells TypeScript: “Trust me, this value is NOT null or undefined.” 🔍 𝗘𝘅𝗮𝗺𝗽𝗹𝗲: const name: string | undefined = undefined; name!.toUpperCase(); 💥 𝗕𝗼𝗼𝗺. 𝗖𝗿𝗮𝘀𝗵. 👉 TypeScript stays quiet 👉 JavaScript throws the error Because YOU told TypeScript: “Trust me” …and it did 😅 🧠 𝗧𝗵𝗲 𝗿𝗲𝗮𝗹 𝗽𝗿𝗼𝗯𝗹𝗲𝗺? ! doesn’t make your code safe It just 𝗵𝗶𝗱𝗲𝘀 𝘁𝗵𝗲 𝘄𝗮𝗿𝗻𝗶𝗻𝗴 🔥 𝗕𝗲𝘁𝘁𝗲𝗿 𝗮𝗽𝗽𝗿𝗼𝗮𝗰𝗵: if (name) { name.toUpperCase(); } ✔ Safe ✔ Predictable ✔ No surprises 👉 If you’re using !, ask yourself: “Am I 100% sure this will never be null?” If not… don’t use it. 💬 𝗛𝗮𝘃𝗲 𝘆𝗼𝘂 𝗲𝘃𝗲𝗿 𝗳𝗮𝗰𝗲𝗱 𝗮 𝗯𝘂𝗴 𝗯𝗲𝗰𝗮𝘂𝘀𝗲 𝗼𝗳 !? #TypeScript #ReactJS #Frontend #WebDevelopment #JavaScript #CodingTips #SoftwareEngineering
To view or add a comment, sign in
-
🚀 I thought I was optimizing my React app… but I was actually wasting time 😅 In my React projects, I used to spend a lot of time on performance optimization: 🔹 "useMemo" 🔹 "useCallback" 🔹 "React.memo" I thought this was the “right way”. But recently, I learned about the React Compiler. It can automatically handle many optimizations that we used to do manually. That made me realize… 👉 I was spending too much time optimizing things that React can handle for me. --- 🔹 What I learned React is evolving. With the compiler: 👉 Many unnecessary re-renders can be optimized automatically 👉 Less need for manual memoization in many cases But this doesn’t mean we stop thinking as developers. --- 🔹 What still matters We still need to focus on: 👉 Code splitting 👉 Lazy loading 👉 Following React best practices 👉 Writing clean and predictable components And most importantly: 👉 Following React rules properly --- 🔹 Reality check The React Compiler is still evolving and improving, so it’s important to understand where it helps and where manual optimization is still needed. So we should: 👉 Understand optimization concepts 👉 Use tools like React DevTools to analyze performance 👉 Apply manual optimization only when needed --- 💡 My takeaway 👉 Don’t over-optimize early 👉 Understand the problem first 👉 Keep learning and stay updated Because in tech: 👉 What worked yesterday may change today Still learning and improving 💻 How do you approach performance optimization in React? 👇 #ReactJS #FrontendDevelopment #WebDevelopment #PerformanceOptimization #JavaScript #LearningJourney #DeveloperMindset
To view or add a comment, sign in
-
Your React app is slow. Here's why. 🐢 Most devs jump straight to optimization tools. But 90% of the time, the fix is simpler: 🔴 Fetching data in every component independently → Lift it up or use a global state solution 🔴 Importing entire libraries for one function → `import _ from 'lodash'` hurts. Use named imports. 🔴 No lazy loading on heavy routes → React.lazy() exists. Use it. 🔴 Images with no defined size → Layout shifts kill perceived performance 🔴 Everything in one giant component → Split it. React re-renders what changed, not what didn't. Performance isn't magic. It's just not making avoidable mistakes. Save this for your next code review. 🔖 #ReactJS #Frontend #WebPerformance #JavaScript #WebDev
To view or add a comment, sign in
-
I used to think I understood React… until I had to pass the same state through 3–4 components just to control one small thing 😅 It worked, but it didn’t feel right. So instead of jumping to another tutorial, I tried to actually "understand the problem" and that led me to the Context API. To keep things simple, I built a tiny “bulb toggle” app 💡 At first, everything was prop-based. Then I switched to Context… and the difference was obvious. Now: 1. I’m not passing props through unnecessary layers 2. Components feel more independent 3. The code is easier to read and reason about But I also learned something important while doing this: 👉 Context is helpful, but it’s not a replacement for everything If the state is simple and only needed in a few places, props are still totally fine. Context starts to make sense when multiple parts of your app need the same data. Still early in my journey, but this was one of those small moments where things started to click. If you’ve worked with Context before -> 👉 how do you decide between props, Context, or other state tools? #learninginpublic #reactjs #webdevelopment #javascript #frontenddevelopment
To view or add a comment, sign in
-
-
🧠 Today I learned something powerful in React: Zustand As I continue building my frontend skills, I explored a lightweight state management library called Zustand — and honestly, it changed the way I think about managing state in React apps. Before this, I mostly used useState and props drilling, which works fine for small apps. But when the app grows, sharing state between components becomes messy and hard to maintain. That’s where Zustand comes in. 🚀 What I learned about Zustand: It allows you to create a global state store outside components Any component can access or update the state directly No need for Context Provider or complex Redux setup Clean, minimal, and very easy to use 💡 Simple idea that helped me understand it: Instead of passing data through components → Zustand keeps the data in one shared store that every component can use directly. This made my code: ✔ Cleaner ✔ More scalable ✔ Easier to manage I really enjoy discovering tools like this because they show me how real-world React applications are structured. Still learning, still building, and getting better every day 💻 #ReactJS #Zustand #FrontendDevelopment #JavaScript #WebDevelopment #LearningInPublic
To view or add a comment, sign in
-
-
🚀 Just launched: react-state-vitals A zero-config memory & render monitor for React apps. While working on production apps, I kept asking: 👉 Why is this component re-rendering so much? 👉 Which store is growing in memory? 👉 Where is my performance actually going? So I built a tool to make this visible — instantly. 🧠 react-state-vitals gives you a live floating panel in development: • 📊 Store size tracking (Zustand, Context, React Query) • 🔁 Re-render counts per component • 🧬 JS heap usage insights • ⚡ Zero setup — just install and see Think of it as: 👉 “Vitals for your React state & memory” 📦 Try it here: https://lnkd.in/gU692hyT 🔥 Next I’m planning: • DevTools-like overlay • Identify memory-heavy components in real time • Visual performance timeline Would love feedback from fellow devs 🙌 What would you want this to track next? #React #JavaScript #Frontend #WebPerformance #OpenSource #NextJS #Zustand
To view or add a comment, sign in
-
🧠 Part 3 of 10: Duplicated state is one of the fastest ways to make a React app feel unstable. Everything looks fine at first. Then one value updates. The other one doesn’t. Now the UI technically works, but nobody fully trusts it. That’s the part people don’t say enough: a lot of frontend bugs are really trust issues. The UI says one thing. The data says another. Now the team starts building around confusion. Whenever I can, I try to keep state close to a single source of truth. It makes code easier to reason about. And future changes get a lot less annoying. What bug have you traced back to duplicated state? #React #ReactJS #FrontendEngineering #StateManagement #JavaScript #UIEngineering #WebDevelopment
To view or add a comment, sign in
-
🧵 Day 5 of 40 — React System Design Series I used to wrap every function in useCallback. Every. Single. One. I thought that's what senior React devs did. Turns out I was making my app slower, not faster. Here's what I learned about useMemo, useCallback, and React.memo: → Memoisation has a cost — it's not free → The trio only works when all three are used together → The Profiler-first rule: measure before you memoize → Exactly when each one helps (and when it's just noise) Full breakdown with real TypeScript code 👇 https://lnkd.in/g5rcJ7qJ #ReactJS #SystemDesign #Frontend #LearningInPublic #WebDevelopment
To view or add a comment, sign in
-
-
Most React developers are writing useEffect wrong. Not because they don't understand it. Because they think they do. After 3 years of building React apps here's what I've learned the hard way: ❌ You don't need useEffect to derive state. ❌ You don't need useEffect to sync two pieces of state. ❌ You definitely don't need useEffect to handle a user event. useEffect is for syncing React with something OUTSIDE React. That's it. That's the rule. When I first started, I put everything in useEffect. Fetch calls. Transformations. Even click handler logic. The bugs were subtle. The re-renders were endless. And the codebase became a nightmare to debug. The fix? Think before you reach for it. Ask yourself: "Am I escaping React, or am I fighting it?" If you're fighting it — useMemo, useCallback, or plain derived variables will serve you better. React is not hard. But undisciplined useEffect usage will make it feel that way. Drop a 🔁 if you've fallen into this trap before. And follow for more no-fluff React breakdowns 👇 #ReactJS #FrontendDevelopment #JavaScript #WebDev #ReactHooks #SoftwareEngineering
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development
Aman Yadav yes, Dependency Array is important which will use to track changes in data whether there is any change its get re-render 1.without [] its re-render and every action or change 2.with[] it will tender once if you want render first time 3.with[val] if will provide dependency it will re-render on its value change cool Keep it up with good content its really help me to brush up my knowledge 🎉🎊