What if most of your 𝘂𝘀𝗲𝗦𝘁𝗮𝘁𝗲… shouldn’t exist at all? Not because it’s wrong— but because it’s in the wrong place. Most "state management problems" today aren't about tools. They're about 𝘄𝗵𝗲𝗿𝗲 𝘄𝗲 𝗽𝘂𝘁 𝘀𝘁𝗮𝘁𝗲. The React Server Components (RSC) shift quietly changed the question: → Not "Which state library should I use?" → But "Should this state even exist on the client?" 🧠 𝗧𝗵𝗲 𝗦𝗵𝗶𝗳𝘁: 𝗦𝘁𝗮𝘁𝗲 𝙋𝙡𝙖𝙘𝙚𝙢𝙚𝙣𝙩 > 𝗦𝘁𝗮𝘁𝗲 𝙈𝙖𝙣𝙖𝙜𝙚𝙢𝙚𝙣𝙩 For years, the default was: fetch data → useState → lift state → global store → more syncing It worked. But also created a lot of accidental complexity: re-fetching, duplication, syncing bugs etc Now we have a different option (with RSC): fetch on the server → render and stream the result → done No client state. No duplication. 📦 𝗟𝗶𝗳𝘁𝗶𝗻𝗴 𝘀𝘁𝗮𝘁𝗲 𝙫𝙨 𝗰𝗼𝗹𝗼𝗰𝗮𝘁𝗶𝗻𝗴 𝗼𝗻 𝘀𝗲𝗿𝘃𝗲𝗿 Instead of pushing state higher in the tree, we can colocate data where its used Or better, keep it on the server entirely • Less prop drilling • Less syncing • Fewer bugs ⚖️ 𝗧𝗿𝗮𝗱𝗲𝗼𝗳𝗳 𝘁𝗼 𝗯𝗲 𝗮𝘄𝗮𝗿𝗲 𝗼𝗳 Too much on the server → sluggish, less interactive UX Too much on the client → same old complexity, syncing issues The skill now is 𝗰𝗵𝗼𝗼𝘀𝗶𝗻𝗴 𝘁𝗵𝗲 𝗯𝗼𝘂𝗻𝗱𝗮𝗿𝘆 𝘄𝗲𝗹𝗹. 💡 𝗙𝗶𝗻𝗮𝗹 𝗧𝗵𝗼𝘂𝗴𝗵𝘁 useState isn't obsolete. But it's no longer the default place to put everything. Modern React is shifting from: "manage state everywhere" to: "decide where state should live in first place". #ReactJS #WebDevelopment #JavaScript #NextJS #StateManagement #ReactServerComponents #SoftwareEngineering
State Management Shift with React Server Components
More Relevant Posts
-
Most React developers start API calls with useEffect(). It works. Until the project gets bigger. Then suddenly: ❌ Manual loading state ❌ Manual error handling ❌ Duplicate API calls ❌ No caching ❌ Refetch logic becomes messy ❌ Background sync becomes difficult ❌ Race conditions become common And your component starts doing too much. That’s when you realize: useEffect is not a data-fetching solution. It is a side-effect hook. That’s where React Query changes everything. useEffect helps you run effects. React Query helps you manage server state. That difference is huge. Use useEffect() for: ✔ Timers ✔ Event listeners ✔ Subscriptions ✔ External system sync ✔ Simple one-time logic Use React Query for: ✔ API fetching ✔ Response caching ✔ Auto refetching ✔ Pagination ✔ Infinite scroll ✔ Mutations ✔ Background updates ✔ Optimistic UI The biggest mistake is using useEffect like a mini backend framework. It was never designed for that. Better architecture: Client state → useState() / useReducer() Server state → React Query That separation creates: ✔ Cleaner code ✔ Better UX ✔ Faster applications ✔ Less debugging ✔ Predictable state management Good React code is not about using fewer libraries. It is about using the right tool for the right problem. Sometimes the best optimization is removing unnecessary code—not adding more. What do you prefer for API calls in production apps: useEffect() or React Query? 👇 #ReactJS #ReactQuery #useEffect #FrontendDevelopment #JavaScript #StateManagement #WebDevelopment #SoftwareEngineering
To view or add a comment, sign in
-
-
Frontend Performance Concepts You Can’t Ignore Scaling a web application isn’t just about handling more users—it’s about delivering a seamless experience, even as your user base grows. Here are six battle-tested strategies to keep your app fast, responsive, and scalable: 1️⃣ CDN for Images Leverage Content Delivery Networks (CDNs) to serve images from edge locations closest to your users. This reduces latency and offloads bandwidth from your origin server. Result: Faster load times, happier users. 2️⃣ Code Splitting Break your JavaScript bundles into smaller chunks using tools like Webpack or Rollup. Load only the code needed for the current view. Result: Quicker initial load and smoother navigation. 3️⃣ Lazy Loading Defer loading non-critical resources (images, iframes, components) until they’re needed. Modern browsers support native lazy loading for images and iframes. Result: Faster perceived performance and lower data usage. 4️⃣ Virtualization of Data Use techniques like windowing or pagination (e.g., React Virtualized, TanStack Table) to render only the data visible in the viewport. Result: Smooth scrolling and snappy UIs, even with massive datasets. 5️⃣ HTTP/1 to HTTP/2 Upgrade to HTTP/2 for multiplexing, header compression, and server push. This reduces round trips and improves parallel loading. Result: Faster page loads and more efficient use of network resources. 6️⃣ Image Optimization Compress, resize, and serve images in modern formats (WebP, AVIF). Use responsive images with srcset and tools like ImageMagick or Cloudinary. Result: Smaller file sizes, faster loads, and lower bandwidth costs. Final Thought: Scaling is not just backend — frontend performance matters just as much. #Frontend #WebPerformance #JavaScript #ReactJS #WebDev #PerformanceOptimization
To view or add a comment, sign in
-
-
Client-side fetching is officially a "Legacy" move 🛑 We’ve all been there: a React page loads, then a spinner appears, then another spinner inside a child component. This "Waterfall" effect is a UX killer. In 2026, the standard is moving data fetching to the server. With React Server Components (RSC), we’re finally fetching data where it lives, close to the database. This means sending zero JavaScript to the client for data-heavy sections. The result? Sub-100ms LCP (Largest Contentful Paint) and a much cleaner codebase. If your useEffect is still doing the heavy lifting for your initial page load, it’s time for a refactor. https://buff.ly/quWlloN #ReactJS #NextJS #WebPerformance #Frontend #CodingBestPractices
To view or add a comment, sign in
-
👉🏻 Stop guessing where your Next.js code actually runs. - Most developers use Next.js… but many overlook the fundamental shift that makes it powerful: 👉 The execution boundary — Server vs Client. And that gap quietly leads to: - Slower applications - Bloated JavaScript bundles - Avoidable security risks If you want to move from just using the framework to mastering it, you need to understand this mental model. ⚡ Server Components — The Heavy Lifters Server Components run exclusively on the server. They are built for: • Data fetching → retrieve data at the source • Security → keep secrets and business logic protected • Performance → send zero JavaScript to the browser 👉 The result: faster load times and leaner applications. ⚡ Client Components — The Interactive Layer Client Components run in the browser. Use them only when necessary: • Interactivity → clicks, forms, UI behavior • State & lifecycle → useState, useEffect • Browser APIs → window, localStorage 👉 They power the experience—but add to your bundle. 💡 The Golden Rule ▪️Server Components → Data, Security, Performance ▪️Client Components → Interaction, State, Experience 📌 Practical Example Think of a dashboard: • Data fetching, layout → Server • Search, filters, actions → Client This separation ensures the browser only handles what truly requires interaction. 🚀 Why this matters Modern applications are judged by speed and efficiency. The more logic you keep on the server, the less JavaScript your users need to download, parse, and execute. #NextJS #WebDevelopment #ReactJS #FullStack #Clientside #Serverside #ReactFramework #Rendering #SIRISAPPS
To view or add a comment, sign in
-
-
⚡7 Advanced React Patterns That Actually Matter in Production 1️⃣ State Colocation > Global State (Most of the Time) Instead of pushing everything into global stores (Redux/Zustand), keep state as close as possible to where it’s used. 👉 This reduces unnecessary re-renders, improves maintainability, and avoids “state explosion.” 2️⃣ Render as You Fetch (Not Fetch on Render) Traditional pattern: render → fetch → re-render ❌ Modern approach: start fetching before rendering (via frameworks like Next.js / RSC). 👉 Result: faster perceived performance and smoother UX. 3️⃣ Avoid “Effect Chains” at All Costs Multiple useEffect hooks triggering each other = hidden complexity. 👉 If your logic depends on sequencing effects, it likely belongs in a single abstraction (custom hook or state machine). 4️⃣ Stale Closures Are Silent Killers Functions inside components capture old state values. 👉 Fix using refs, functional updates, or by restructuring logic — not by blindly adding dependencies. 5️⃣ Memoization is a Trade-off, Not a Default useMemo / useCallback add overhead and complexity. 👉 Only use them when you measure a real performance issue — not “just in case.” 6️⃣ Component Boundaries Define Performance Where you split components impacts re-renders more than most optimizations. 👉 Smaller, well-defined boundaries = more predictable updates. 7️⃣ Server Components Change Data Flow Thinking With React Server Components: Data fetching moves to the server Less JS is shipped to the client Components become split across environments 👉 This is not just optimization — it’s a new mental model for building apps React performance and scalability don’t come from tricks —they come from understanding data flow, boundaries, and rendering behavior deeply. If you’re building or scaling serious React applications, these patterns are no longer “advanced” — they’re expected. #ReactJS #AdvancedReact #FrontendEngineering #WebPerformance #NextJS #ReactPatterns #JavaScript #SoftwareEngineering #TheReactHub
To view or add a comment, sign in
-
Most React performance issues don’t come from heavy components. They come from Context API used the wrong way. Many developers create one large context like this: User + Theme + Settings + Permissions + Notifications Looks clean. Feels scalable. But every time one value changes, all consuming components re-render. Even components that don’t use the updated value. That means: Theme changed → User components re-render User updated → Settings components re-render This creates silent performance problems in large applications. Why? Because React checks the Provider value by reference, not by which field changed. New object reference = Re-render. How to fix it: ✔ Split contexts by concern ✔ Use useMemo() for provider values ✔ Use useCallback() for functions ✔ Use selector patterns for larger applications Context API is powerful, but bad context design creates expensive re-renders. Good performance starts with good state architecture. Don’t just use Context. Use it wisely. #ReactJS #ContextAPI #JavaScript #FrontendDevelopment #PerformanceOptimization #WebDevelopment #ReactDeveloper #SoftwareEngineering
To view or add a comment, sign in
-
-
Let’s talk about useEffect. Not just how to use it… but how to use it properly. Because this is where a lot of frontend issues start. First thing to understand: useEffect is for side effects. That means anything outside the normal render flow: – API calls – subscriptions – timers – interacting with the DOM It’s not a general-purpose tool for logic. Where most people get it wrong: They treat useEffect like: “run this code when the component loads” And then you start seeing things like: – multiple API calls – infinite loops – unnecessary re-renders – state updating in circles A simple example: If you do this: useEffect(() => { fetchData(); }); That runs on every render. Now imagine what happens when state updates… The correct approach is to be intentional: – run once → use [] – run on change → add specific dependencies But here’s the shift that changed things for me: I stopped asking “where can I use useEffect?” And started asking “do I even need useEffect here?” Because in many cases, you don’t. Instead: – derive values directly during render – use event handlers for interactions – use tools like React Query (TanStack Query) for data fetching React Query handles: – caching – background updates – loading & error states – request deduplication So you don’t have to manually manage all of that inside useEffect. That shift alone removes a lot of bugs. useEffect is not a “run code” tool. It’s a synchronisation tool. Once you understand that… your code becomes simpler and more predictable. #React #ReactQuery #Frontend #WebDevelopment #JavaScript #SoftwareEngineering
To view or add a comment, sign in
-
-
Refactoring for Scalability: From individual states to clean, centralized objects. 🏗️ I’ve been spending my weekend deep-diving into React state management for my latest project, the Lumina Tech. The biggest "aha!" moment? Moving away from multiple useState hooks for every single input and refactoring my form logic into a single source of truth. By using a generic handleChange function with the Context API, I can now handle Name, Price, Category, and Quantity updates with just one clean function. It’s one thing to make a form work; it’s another to make it scalable. Current progress on the Lumina Tech: ✅ Centralized State: Managed via React Context for a cleaner component tree. ✅ Draft vs. Confirmed Logic: Separating "live typing" from the final "catalog upload." ✅ Professional UI: Leveraged react-icons and custom CSS for a modern inventory dashboard. Next up: Implementing the product grid and mastering nested routing! #ReactJS #WebDevelopment #FrontendEngineers #CodingJourney #JavaScript #BuildInPublic
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
-
-
⚛️ 𝗔𝘃𝗼𝗶𝗱𝗶𝗻𝗴 𝗢𝘃𝗲𝗿-𝗘𝗻𝗴𝗶𝗻𝗲𝗲𝗿𝗲𝗱 𝗦𝘁𝗮𝘁𝗲 𝗠𝗮𝗻𝗮𝗴𝗲𝗺𝗲𝗻𝘁 𝗶𝗻 𝗥𝗲𝗮𝗰𝘁 In many React applications, state management becomes more complex than it actually needs to be. 𝗔 𝗰𝗼𝗺𝗺𝗼𝗻 𝗽𝗮𝘁𝘁𝗲𝗿𝗻: • adding Redux / global state too early • moving all state to global store • increasing boilerplate and complexity But not all state needs to be global. ❌ 𝗢𝘃𝗲𝗿-𝗲𝗻𝗴𝗶𝗻𝗲𝗲𝗿𝗲𝗱 𝗮𝗽𝗽𝗿𝗼𝗮𝗰𝗵 // 𝘨𝘭𝘰𝘣𝘢𝘭 𝘴𝘵𝘰𝘳𝘦 𝘧𝘰𝘳 𝘦𝘷𝘦𝘳𝘺𝘵𝘩𝘪𝘯𝘨 𝘤𝘰𝘯𝘴𝘵 𝘶𝘴𝘦𝘳 = 𝘶𝘴𝘦𝘚𝘦𝘭𝘦𝘤𝘵𝘰𝘳(𝘴𝘵𝘢𝘵𝘦 => 𝘴𝘵𝘢𝘵𝘦.𝘶𝘴𝘦𝘳); 𝘤𝘰𝘯𝘴𝘵 𝘵𝘩𝘦𝘮𝘦 = 𝘶𝘴𝘦𝘚𝘦𝘭𝘦𝘤𝘵𝘰𝘳(𝘴𝘵𝘢𝘵𝘦 => 𝘴𝘵𝘢𝘵𝘦.𝘵𝘩𝘦𝘮𝘦); 𝘤𝘰𝘯𝘴𝘵 𝘮𝘰𝘥𝘢𝘭 = 𝘶𝘴𝘦𝘚𝘦𝘭𝘦𝘤𝘵𝘰𝘳(𝘴𝘵𝘢𝘵𝘦 => 𝘴𝘵𝘢𝘵𝘦.𝘮𝘰𝘥𝘢𝘭); Even simple UI states are stored globally. This makes: • debugging harder • components tightly coupled • unnecessary re-renders ✅ Practical approach Use state based on scope: • local state → useState • shared state → Context API • server state → React Query • global app state → only when truly needed 𝗘𝘅𝗮𝗺𝗽𝗹𝗲: 𝘧𝘶𝘯𝘤𝘵𝘪𝘰𝘯 𝘔𝘰𝘥𝘢𝘭() { 𝘤𝘰𝘯𝘴𝘵 [𝘪𝘴𝘖𝘱𝘦𝘯, 𝘴𝘦𝘵𝘐𝘴𝘖𝘱𝘦𝘯] = 𝘶𝘴𝘦𝘚𝘵𝘢𝘵𝘦(𝘧𝘢𝘭𝘴𝘦); 𝘳𝘦𝘵𝘶𝘳𝘯 ( <> <𝘣𝘶𝘵𝘵𝘰𝘯 𝘰𝘯𝘊𝘭𝘪𝘤𝘬={() => 𝘴𝘦𝘵𝘐𝘴𝘖𝘱𝘦𝘯(𝘵𝘳𝘶𝘦)}>𝘖𝘱𝘦𝘯</𝘣𝘶𝘵𝘵𝘰𝘯> {𝘪𝘴𝘖𝘱𝘦𝘯 && <𝘥𝘪𝘷>𝘔𝘰𝘥𝘢𝘭 𝘊𝘰𝘯𝘵𝘦𝘯𝘵</𝘥𝘪𝘷>} </> ); } 📌 𝗣𝗿𝗼𝗱𝘂𝗰𝘁𝗶𝗼𝗻 𝗺𝗶𝗻𝗱𝘀𝗲𝘁: • keep state as close as possible to where it’s used • avoid global store for UI state • introduce tools only when required • prefer simplicity over abstraction 📌 𝗪𝗵𝘆 𝘁𝗵𝗶𝘀 𝗺𝗮𝘁𝘁𝗲𝗿𝘀: • cleaner architecture • better performance • easier debugging • more maintainable code Not every problem needs a global state solution. Sometimes, simple patterns scale better. 💬 Curious — Do you decide state location upfront, or refactor as the app grows? #ReactJS #StateManagement #FrontendDevelopment #JavaScript #WebDevelopment #SoftwareEngineering #CleanCode #ReactArchitecture
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
If you're new to RSCs and want the bigger picture behind this shift, I broke it down here earlier: https://www.garudax.id/posts/myself-shafi_react-nextjs-webdevelopment-activity-7438086440716087296-mIl8 This post builds on that idea—specifically why a lot of client state might not need to exist anymore.