🟨 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗗𝗮𝘆 𝟲𝟮: 𝗪𝗵𝘆 𝗗𝗢𝗠 𝗨𝗽𝗱𝗮𝘁𝗲𝘀 𝗔𝗿𝗲 𝗮 𝗣𝗿𝗼𝗯𝗹𝗲𝗺 (𝗔𝗻𝗱 𝗛𝗼𝘄 𝗥𝗲𝗮𝗰𝘁 𝗧𝗵𝗶𝗻𝗸𝘀 𝗗𝗶𝗳𝗳𝗲𝗿𝗲𝗻𝘁𝗹𝘆) Updating UI looks simple… until it isn’t. 🔹 𝗛𝗼𝘄 𝗨𝗜 𝗨𝗽𝗱𝗮𝘁𝗲𝘀 𝗪𝗼𝗿𝗸 (𝗪𝗶𝘁𝗵𝗼𝘂𝘁 𝗥𝗲𝗮𝗰𝘁) • We directly update the DOM • We decide what to change and how Example: document.getElementById("title").innerText = "Hello" 🔹 𝗧𝗵𝗲 𝗣𝗿𝗼𝗯𝗹𝗲𝗺 • DOM operations are relatively expensive • You must track what changed manually • Easy to make mistakes • Becomes complex as UI grows 🔹 𝗪𝗵𝗮𝘁 𝗺𝗮𝗸𝗲𝘀 𝗶𝘁 𝗵𝗮𝗿𝗱 • UI = multiple states + frequent updates • Small changes can affect many elements • Manual DOM handling doesn’t scale well 🔹 𝗪𝗵𝗮𝘁 𝗥𝗲𝗮𝗰𝘁 𝗖𝗵𝗮𝗻𝗴𝗲𝘀 • You don’t update DOM directly • You describe what UI should look like • React figures out the most efficient way to update 🔹 𝗞𝗲𝘆 𝗜𝗱𝗲𝗮 • Shift from “How to update UI” • To “What should UI look like” 🔹 𝗧𝗵𝗲 𝗠𝗶𝘀𝘀𝗶𝗻𝗴 𝗣𝗶𝗲𝗰𝗲 👉 But how does React know what actually changed? 👉 This is where Virtual DOM comes in 👉 React creates a representation of UI and compares it before updating the real DOM 🔹 𝗠𝗼𝘀𝘁 𝗜𝗺𝗽𝗼𝗿𝘁𝗮𝗻𝘁 𝗜𝗻𝘀𝗶𝗴𝗵𝘁 • Problem is NOT creating UI • Problem is updating it efficiently 💬 GitHub link in comments. #JavaScript #React #Frontend #Day62 #100DaysOfCode
Nishchaya Narula’s Post
More Relevant Posts
-
𝐘𝐨𝐮 𝐦𝐢𝐠𝐡𝐭 𝐛𝐞 𝐨𝐯𝐞𝐫𝐭𝐡𝐢𝐧𝐤𝐢𝐧𝐠 𝐬𝐭𝐚𝐭𝐞 𝐮𝐩𝐝𝐚𝐭𝐞𝐬 𝐢𝐧 𝐑𝐞𝐚𝐜𝐭 𝟏𝟖. Remember the days of `ReactDOM.unstable_batchedUpdates` or manually wrapping multiple `setState` calls to prevent excessive re-renders? Good news: React 18 made those mostly obsolete with automatic batching. Now, pretty much any updates—inside event handlers, promises, or `setTimeout`—are batched together into a single re-render. It's a huge win for performance out of the box! However, there's always an escape hatch: `ReactDOM.flushSync()`. This function forces React to process any pending state updates synchronously and update the DOM immediately. While powerful, it's rarely needed and should be used with extreme caution. **When might you reach for `flushSync`?** * **Immediate DOM measurements:** If you need to read the updated DOM layout right after a state change (e.g., for complex animations or integrating with non-React UI libraries) before the browser paints the next frame. * **Controlling browser painting:** For very specific, imperative UI sequences where you need a synchronous render cycle. For 99% of use cases, React's automatic batching handles performance beautifully. Reaching for `flushSync` is usually a sign you might be fighting React's reconciliation process, not working with it. What's the most obscure React API you've had to use for a specific UI challenge? #React #ReactJS #Performance #Frontend #WebDev #JavaScript
To view or add a comment, sign in
-
Most people think UI development is slow, messy, and full of compromises It doesn’t have to be Here’s a combo that completely changed how I build interfaces: ⚛️ React 🎨 Tailwind CSS 🧩 shadcn/ui This stack is not just about building fast—it's about building clean, scalable, and beautiful UIs without fighting your code Why it works so well: Tailwind CSS → utility-first, no more context switching between files shadcn/ui → real components you own (not a black box library) React → flexible architecture to scale anything 👉 The real power? You’re not installing a heavy UI framework You’re composing your own design system No more: ❌ overriding endless CSS ❌ fighting component libraries ❌ inconsistent design Instead: ✅ full control over UI ✅ consistent, reusable components ✅ modern, clean design out of the box This is how a modern frontend should feel: fast, flexible, and actually enjoyable If you’re still stuck with bloated UI libraries… it might be time to switch What’s your go-to UI stack right now? #ReactJS #TailwindCSS #shadcn #FrontendDevelopment #UIUX #WebDevelopment #JavaScript #DesignSystems #CleanCode #DeveloperExperience #Programming #DevCommunity
To view or add a comment, sign in
-
-
𝘂𝘀𝗲𝗘𝗳𝗳𝗲𝗰𝘁 𝘃𝘀 𝘂𝘀𝗲𝗟𝗮𝘆𝗼𝘂𝘁𝗘𝗳𝗳𝗲𝗰𝘁 𝗶𝗻 𝗥𝗲𝗮𝗰𝘁 — 𝗖𝗵𝗼𝗼𝘀𝗶𝗻𝗴 𝘁𝗵𝗲 𝗥𝗶𝗴𝗵𝘁 𝗛𝗼𝗼𝗸 𝗮𝘁 𝘁𝗵𝗲 𝗥𝗶𝗴𝗵𝘁 𝗧𝗶𝗺𝗲 React gives developers powerful hooks to manage side effects, but understanding when each hook runs can make a significant difference in UI performance and user experience. Two commonly misunderstood hooks are: 🔹 𝘂𝘀𝗲𝗘𝗳𝗳𝗲𝗰𝘁() useEffect runs after the browser has painted the UI. This makes it the right choice for: • API requests • Event listeners • Subscriptions • Logging • Updating external systems Because it runs after paint, it does not block rendering, helping keep your application fast and responsive. 🔹 𝘂𝘀𝗲𝗟𝗮𝘆𝗼𝘂𝘁𝗘𝗳𝗳𝗲𝗰𝘁() useLayoutEffect runs immediately after the DOM updates but before the browser paints the screen. This makes it useful for: • Reading element dimensions • Measuring layout • Scroll position adjustments • Preventing visual flicker • Synchronizing DOM changes before display Since it runs before paint, users never see intermediate layout changes. 𝗪𝗵𝘆 𝗶𝘁 𝗺𝗮𝘁𝘁𝗲𝗿𝘀 Using the wrong hook can lead to: ❌ Layout shifts ❌ Flickering UI ❌ Incorrect measurements ❌ Less predictable rendering behavior Choosing the correct hook leads to: ✅ Smoother interfaces ✅ Better visual stability ✅ More predictable components 𝗦𝗶𝗺𝗽𝗹𝗲 𝗿𝘂𝗹𝗲 𝗼𝗳 𝘁𝗵𝘂𝗺𝗯 Use useEffect → for most side effects Use useLayoutEffect → when layout or visual updates must happen before paint Small React details like this often separate working code from polished frontend engineering. #React #JavaScript #FrontendDevelopment #WebDevelopment #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 React Render vs Commit Phase — How React Actually Updates UI Most developers know: 👉 React re-renders components But what really happens behind the scenes? 👉 React works in two phases 💡 1. Render Phase (Calculation Phase) 👉 React prepares what needs to change ✔ Creates new Virtual DOM ✔ Compares with previous tree (Reconciliation) ✔ Decides what to update ❗ No DOM updates happen here 💡 2. Commit Phase (Execution Phase) 👉 React applies the changes to the real DOM ✔ Updates DOM ✔ Runs useEffect ✔ Updates refs 👉 This is where UI actually changes ⚙️ Flow (Step-by-step) 1️⃣ State/props change 2️⃣ Render Phase runs (diffing) 3️⃣ React calculates changes 4️⃣ Commit Phase updates DOM 🧠 Why this matters 👉 React separates thinking from doing: Render Phase → “What to update?” Commit Phase → “Apply updates” 🔥 Important Behavior ✔ Render phase can run multiple times ✔ Commit phase runs once per update 👉 This enables features like: Concurrent rendering Interruptible updates ⚠️ Common Mistake // ❌ Side effects in render const data = fetchData(); 👉 Causes bugs → should be inside useEffect 🔥 Best Practices ✅ Keep render phase pure ✅ Avoid side effects in render ✅ Use useEffect for side effects ❌ Don’t trigger DOM changes in render 💬 Pro Insight (Senior-Level Thinking) 👉 Render phase can be paused, restarted, or discarded 👉 Commit phase is always final 📌 Save this post & follow for more deep frontend insights! 📅 Day 23/100 #ReactJS #FrontendDevelopment #JavaScript #ReactInternals #PerformanceOptimization #SoftwareEngineering #100DaysOfCode 🚀
To view or add a comment, sign in
-
-
𝗥𝗲𝗮𝗰𝘁 𝗙𝘂𝗻𝗱𝗮𝗺𝗲𝗻𝘁𝗮𝗹 𝗜𝗻𝘁𝗲𝗿𝘃𝗶𝗲𝘄 𝗤𝘂𝗲𝘀𝘁𝗶𝗼𝗻: 𝗪𝗵𝗮𝘁 𝗶𝘀 𝘁𝗵𝗲 𝗱𝗶𝗳𝗳𝗲𝗿𝗲𝗻𝗰𝗲 𝗯𝗲𝘁𝘄𝗲𝗲𝗻 𝗦𝗵𝗮𝗱𝗼𝘄 𝗗𝗢𝗠 𝗮𝗻𝗱 𝗩𝗶𝗿𝘁𝘂𝗮𝗹 𝗗𝗢𝗠? This is one of those questions where many developers get confused because both sound similar, but they solve completely different problems. 🔹 𝗦𝗵𝗮𝗱𝗼𝘄 𝗗𝗢𝗠 (𝗕𝗿𝗼𝘄𝘀𝗲𝗿 𝗙𝗲𝗮𝘁𝘂𝗿𝗲) Shadow DOM is used for encapsulation. It creates a separate, isolated DOM tree inside a component. why use Shadow DOM? - styles are scoped (no leaking in or out) - internal markup is isolated from the main DOM - enables reusable Web Components - avoids CSS conflicts in large applications 🔹 𝗩𝗶𝗿𝘁𝘂𝗮𝗹 𝗗𝗢𝗠 (𝗥𝗲𝗮𝗰𝘁 𝗖𝗼𝗻𝗰𝗲𝗽𝘁) Virtual DOM is used for performance optimization. It is a lightweight JavaScript representation of the real DOM. how it works: - react creates a Virtual DOM - on state change it creates a new Virtual DOM - compares with the old one (diffing) - updates only the changed parts in the real DOM why use Virtual DOM ? - faster updates - efficient rendering - less direct DOM manipulation 🔹 𝗞𝗲𝘆 𝗗𝗶𝗳𝗳𝗲𝗿𝗲𝗻𝗰𝗲 Shadow DOM = Encapsulation Virtual DOM = Performance 🔹 𝗤𝘂𝗶𝗰𝗸 𝗖𝗼𝗺𝗽𝗮𝗿𝗶𝘀𝗼𝗻 Shadow DOM → isolates structure & styles Virtual DOM → optimizes rendering updates Shadow DOM → browser feature Virtual DOM → React (library concept) Connect/Follow Tarun Kumar for more tech content and interview prep #ReactJS #JavaScript #FrontendDevelopment #WebDevelopment #ReactInterview #WebComponents #SoftwareEngineering #CodingInterview
To view or add a comment, sign in
-
🚀 This repo blew my mind: “Stop writing skeleton loaders manually” Came across an interesting project: 👉 0xGF/boneyard --- 💡 Problem every frontend dev knows: You build a UI… Then you build a separate skeleton loader And slowly… they go out of sync 😅 --- 🔥 What this repo does differently: Instead of manually coding skeletons It generates them automatically from your real DOM --- ⚙️ How it works (crazy part): • Uses a headless browser (Playwright) • Scans your actual rendered UI • Extracts layout (positions, sizes) • Generates pixel-perfect skeletons 👉 Basically treating skeletons as a compiled output, not UI code! --- ⚡ Why this is powerful: ✅ No layout shift ✅ No duplicate maintenance ✅ Works with real UI structure ✅ Zero runtime cost (done at build time) --- 🧠 Big insight: We’ve been treating skeleton loaders as design work But this flips it into a build-time engineering problem --- 🎯 Takeaway: The future of frontend isn’t writing more UI… It’s generating UI from existing sources --- This is one of those ideas that feels obvious… but only after you see it 👀 --- #frontend #reactjs #webdevelopment #performance #opensource #javascript #uiux https://lnkd.in/dRJxV9Yv
To view or add a comment, sign in
-
-
Modern CSS is having a moment — and it’s making UI code dramatically more maintainable. Three features I keep reaching for: - **Container Queries** Components can respond to the size of their *container*, not just the viewport. That means truly reusable UI that adapts wherever it’s placed. - **Cascade Layers** A cleaner way to control style precedence without fighting specificity wars. Great for organizing resets, design tokens, components, and utilities. - **`:has()` selector** The long-awaited “parent selector” unlocks patterns that used to need JavaScript. Think smarter form validation states, conditional layouts, and richer interactions. Why this matters: Modern CSS is shifting from “workarounds and overrides” to **intentional, scalable styling architecture**. We’re finally getting tools that make components more portable, styles more predictable, and codebases easier to evolve. If you haven’t revisited CSS lately, now’s a good time. **Which modern CSS feature has had the biggest impact on your workflow?** #CSS #WebDevelopment #Frontend #UIDesign #ResponsiveDesign #SoftwareEngineering Summary: Wrote a concise LinkedIn post highlighting container queries, cascade layers, and `:has()` with a professional, engaging tone. #WebDevelopment #TypeScript #Frontend #JavaScript
To view or add a comment, sign in
-
Tired of building UI from scratch every time… So I built my own Component Library ⚡ 🔗 GitHub: https://lnkd.in/gz_vRwND 🔗 Vercel: https://lnkd.in/gjwbZbcA ✨ Built with React + Tailwind ✨ Clean & reusable components ✨ Live preview + copy code ✨ Dark mode + responsive How to use: 1. Browse components 2. Click "Show Code" 3. Copy & paste into your project 4. Customize as needed “Browse → Copy → Use → Customize” This project helped me improve: UI design thinking Component reusability Real-world frontend skills Still improving it — feedback is welcome 🙌 #ReactJS #TailwindCSS #FrontendDeveloper #WebDevelopment #UIUX #JavaScript #OpenSource #100DaysOfCode #Developer #Portfolio
To view or add a comment, sign in
-
Have you ever built a perfectly designed tooltip or modal only to find it cut off by its parent container? It is the classic CSS 'overflow: hidden' trap. Your parent component needs to clip its own content, but your child component, like a dropdown or a popup, needs to break free from those boundaries to be visible. Because the child is physically nested inside the parent in the DOM, it is bound by the parent's styling rules and stacking context. This is exactly why React Portals exist. They provide a way to render a child into a different DOM node that exists outside the parent's hierarchy. Even though the child stays part of the React component tree and can still receive props or communicate with the parent, it physically lives somewhere else in the HTML, such as a div at the very end of the body tag. By teleporting the UI, you bypass the parent's 'overflow' and 'z-index' constraints entirely. Your tooltip can now float freely over the rest of the application without you having to mess with the parent's CSS and potentially breaking the rest of your layout. It is the ultimate escape hatch for complex UI components that need to live independently of their logical parents. It keeps your DOM structure clean and your UI accessible without the headache of fighting CSS inheritance. #ReactJS #SoftwareEngineering #WebDevelopment #Frontend #Javascript #CodingTips
To view or add a comment, sign in
-
-
Container queries are the difference between a component that "kind of" works in your design system and one that actually adapts. They ask the size of the parent, not the viewport, which is the right unit for reusable UI. https://lnkd.in/eMMBmVQy #WebDev #CSS #WebPlatform
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
https://github.com/nishchaya2k