🚨 𝗥𝗲𝗮𝗰𝘁 𝗖𝗼𝗱𝗲 𝗦𝗺𝗲𝗹𝗹 #𝟬𝟵: 𝗠𝗼𝗻𝘀𝘁𝗲𝗿 𝗖𝗼𝗺𝗽𝗼𝗻𝗲𝗻𝘁𝘀 When a component fetches data, manages state, and renders UI, it starts to grow fast. Over time, these “do everything” components become painful to maintain. 👉 Move data logic into custom hooks 👉 Keep components focused on rendering 👉 Smaller pieces scale better Good React architecture is about the separation of concerns. How big is the largest component in your codebase? 😄 #React #CleanCode #CodeSmell #Frontend #JavaScript #ReactHooks
React Code Smell: Large Components
More Relevant Posts
-
⚡ “The Event Loop Trap — Why Your Code Runs Out of Order” You write this 👇 console.log("Start"); setTimeout(() => console.log("Timeout"), 0); Promise.resolve().then(() => console.log("Promise")); console.log("End"); Expected output? Start → Timeout → Promise → End Reality? Start → End → Promise → Timeout 👉 That’s the event loop catching you off guard. 🧠 Why This Happens JavaScript is single‑threaded but non‑blocking. The event loop orchestrates execution: Call Stack → Runs synchronous code first. Microtask Queue → Promises, await, queueMicrotask. Macrotask Queue → setTimeout, setInterval, DOM events. Loop → Sync → Microtasks → ONE Macrotask → Repeat 🔁 🚀 Angular Example In Angular 21–22 apps: You poll APIs every few seconds. You rely on signals + OnPush for reactivity. If you assume setTimeout(fn, 0) runs immediately, your UI may render stale data or lag behind user actions. Promise.resolve().then(() => console.log('Microtask')); setTimeout(() => console.log('Macrotask'), 0); Output: Microtask → Macrotask Angular’s signal‑first runtime depends on this ordering for predictable updates. ⚖️ Golden Rule (Never Forget) 1️⃣ Sync code first 2️⃣ Then all microtasks 3️⃣ Then one macrotask 🔁 Repeat 🔥 Why This Matters Debugging async issues Avoiding race conditions Predictable UI rendering Understanding why logs look “out of order” What output did you expect before reading this? 😅 #JavaScript #EventLoop #Angular #Signals #OnPush #Frontend #Performance #WebDevelopment #CleanCode #AsyncProgramming
To view or add a comment, sign in
-
-
𝗦𝗹𝗶𝗺𝗺-𝗣𝗮𝗰𝗸 𝗩𝘀 𝗧𝗿𝗲𝗲-𝘀𝗵𝗮𝗸𝗶𝗻𝗴 Tree-shaking runs every build. Slimm-Pack doesn’t. Traditional tools: analyze → build → forget 𝗜𝗼𝗻𝗶𝗳𝘆: analyze → store → reuse This is not optimization. This is a different architecture. #WebDev #Frontend #Javascript #React #Webpack #Ionify
To view or add a comment, sign in
-
-
Your landing page fetches data from 20+ APIs. The user expects it to load in 2 seconds. Most frontend engineers would reach for Promise.all and call it a day. That approach is wrong and I wrote 4,000 words explaining why. (It's a very very deep dive and solution oriented) HTTP 103 Early Hints. The RSC Flight Protocol. WHATWG Streams with backpressure. Transferable ReadableStreams piped through Web Workers. Origin Private File System. scheduler.yield(). Speculation Rules API. These are all shipping browser capabilities. Today. Right now. Most of us have never used them. I wrote a deep-dive system design on how to architect a frontend that fetches massive data from N sources and still paints meaningful content in under 500ms. No bullet-point listicle. Just the actual engineering. check the link in the comment! #React #Javascript #Frontend #SystemDesign
To view or add a comment, sign in
-
-
🔥 Part 4 of 10: A React component doing 5 jobs is usually a warning sign. Not because long files are automatically bad. But because once one component is fetching data transforming data handling UI state managing side effects and rendering half the page… the structure usually stopped making sense. I’ve learned that a lot of frontend cleanup is really just responsibility cleanup. What belongs here? What should move out? What’s making this harder than it needs to be? Cleaner React usually comes from clearer boundaries. Not fancier patterns. What’s your rule for when a component is doing too much? #React #FrontendArchitecture #ReactJS #SoftwareEngineering #TypeScript #FrontendDeveloper #CodeQuality
To view or add a comment, sign in
-
If there’s one thing I’ve learned while building out large-scale, modular applications, it’s that component bloat will quietly ruin your codebase. React components usually start small, but once you add data fetching, sorting, and state management, they become monstrous. I just published a new article on Medium breaking down my favorite solution to this: Custom Hooks. I explain the golden rule of clean React architecture—separating the "Brains" (logic) from the "Looks" (UI)—and how to actually implement it. If you want to write cleaner, more testable code, give it a read: "https://lnkd.in/gnZ44Hgu" #ReactJS #WebDevelopment #SoftwareArchitecture #CleanCode #FrontendDeveloper
To view or add a comment, sign in
-
Race conditions are not just backend problems. They exist in your UI too. And they’re harder to notice. Here’s a real scenario 👇 User types fast in a search box: → Request A (slow) → Request B (fast) Response order: → B returns first → A returns later Now UI shows: ❌ Old data (A) instead of latest (B) No crash. Just wrong UI. Where this happens: ✖ Search inputs ✖ Filters ✖ Rapid navigation What works: ✔ Cancel previous requests (AbortController) ✔ Track latest request ID ✔ Use libraries that handle this (React Query) Key insight: UI correctness is not about rendering. It’s about timing. If you ignore race conditions… Your UI will lie to users. #ReactJS #Frontend #RaceCondition #JavaScript #SoftwareEngineering #Async #AdvancedReact #Engineering #WebDevelopment #Tech
To view or add a comment, sign in
-
Shipped my latest front-end project — an Async Weather Tracker built with vanilla JS. ☁️ Key features: - Live weather data via OpenWeatherMap API - async/await for all API calls - Search history stored in localStorage - Clean, minimal UI redesign Check it out here 👇 https://lnkd.in/g_kQZ6ad Still learning, still building. #JavaScript #FrontEnd #WebDevelopment #StudentProject
To view or add a comment, sign in
-
-
Evolving React Architecture from Context to Service Layer Today, I took a step toward senior-level React architecture by refactoring my state management logic. Instead of letting a "God Context" handle everything, I introduced a Service Layer for data persistence. By abstracting localStorage logic into a dedicated storage service, I’ve achieved: 1- Decoupled UI & Data: My components no longer care how data is stored. 2- Easier Scaling: Switching from LocalStorage to a real API now only requires touching one file. 3- Clean Code: My Context files are leaner and easier to maintain. Senior-level development isn't just about making things work—it’s about making things scale. #ReactJS #WebDevelopment #SoftwareArchitecture #CleanCode #JavaScript
To view or add a comment, sign in
-
When it comes to file structure: ⚡ React → You build your own architecture ⚡ Next.js → Architecture is built for you Both approaches have pros & trade-offs. 💬 What do you prefer as a developer — flexibility or convention? #ReactJS #NextJS #SoftwareEngineering #FrontendDev #CodingLife #TechCommunity #TechoSkills
To view or add a comment, sign in
-
-
localStorage vs sessionStorage in JavaScript frontend Both are used to store data in the browser, but choosing the right one is important for application behavior localStorage Data persists even after closing the browser Shared across all tabs of the same origin Best suited for long term data like user preferences sessionStorage Data exists only for the duration of the tab session Cleared when the tab is closed Isolated per tab Best suited for temporary data like session state Key difference comes down to data lifecycle and scope localStorage for persistence sessionStorage for session based isolation Using the wrong storage can lead to unexpected user experience issues Frontend decisions are not just UI level They directly impact how users interact with your application #javascript #frontend #performance
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