🚀 𝗕𝘂𝗶𝗹𝘁 & 𝗣𝘂𝗯𝗹𝗶𝘀𝗵𝗲𝗱: 𝘂𝘀𝗲-𝘁𝗵𝗲𝗺𝗲-𝗺𝗼𝗱𝗲 🌗 𝘈 𝘭𝘪𝘨𝘩𝘵𝘸𝘦𝘪𝘨𝘩𝘵 𝘙𝘦𝘢𝘤𝘵 𝘩𝘰𝘰𝘬 𝘧𝘰𝘳 𝘥𝘢𝘳𝘬/𝘭𝘪𝘨𝘩𝘵 𝘮𝘰𝘥𝘦 Dark mode shouldn’t be complicated or overly opinionated. That’s why I built 𝘂𝘀𝗲-𝘁𝗵𝗲𝗺𝗲-𝗺𝗼𝗱𝗲, an open‑source React hook that focuses purely on 𝘁𝗵𝗲𝗺𝗲 𝘀𝘁𝗮𝘁𝗲 𝗺𝗮𝗻𝗮𝗴𝗲𝗺𝗲𝗻𝘁, while giving developers full control over styling. ✅ 𝗪𝗵𝗮𝘁 𝗶𝘁 𝗵𝗮𝗻𝗱𝗹𝗲𝘀 𝗼𝘂𝘁 𝗼𝗳 𝘁𝗵𝗲 𝗯𝗼𝘅: • Light and dark theme switching • System preference detection (prefers-color-scheme) • Persistent theme using localStorage • Cross‑tab theme synchronization • SSR‑safe (works with Next.js) • Zero runtime dependencies You control the UI. The hook handles the logic. 🔗 𝗟𝗶𝘃𝗲 𝗗𝗲𝗺𝗼: https://lnkd.in/d2AprnYd 📝 𝗙𝘂𝗹𝗹 𝘁𝗲𝗰𝗵𝗻𝗶𝗰𝗮𝗹 𝗯𝗹𝗼𝗴 𝗼𝗻 𝗗𝗘𝗩.𝘁𝗼: https://lnkd.in/d78gT_zB 📦 𝗻𝗽𝗺 𝗽𝗮𝗰𝗸𝗮𝗴𝗲: https://lnkd.in/dHF6iM7T This project was a great learning experience around: • npm publishing & versioning • token‑based npm security • documentation & demos • shipping production‑ready open source Feedback, suggestions, and contributions are always welcome 🚀 #React #JavaScript #Frontend #OpenSource #WebDevelopment #NPM #DarkMode #OSS
Saad Ahmad’s Post
More Relevant Posts
-
How you structure your projects matters as much as the code itself! 📂🚀 Organization isn't just about finding files faster; it’s the foundation of scalability and maintainability. A well-structured project makes collaboration seamless and keeps technical debt to a minimum. In my recent work, I’ve been prioritizing a modular folder structure similar to this one. By clearly separating Features, Hooks, and Services, the codebase stays clean and easy to navigate even as the application grows in complexity. What does your favorite frontend folder structure look like? Let’s discuss in the comments! 👇 #WebDevelopment #Frontend #CleanCode #ReactJS #SoftwareEngineering #ProgrammingTips #JavaScript
To view or add a comment, sign in
-
-
🚀 Debounce vs Throttle in React (and when to use each) Handling user interactions efficiently is key to building performant applications — especially when dealing with frequent events like typing and scrolling. Here’s a simple breakdown: 🔹 Debounce • Delays execution until the user stops triggering the event • Best for: search inputs, API calls on typing 🔹 Throttle • Limits execution to once every fixed interval • Best for: scroll events, resize handlers ⚠️ Without control, frequent events can lead to: • Too many API calls • UI lag • Performance issues 📈 Results: • Reduced unnecessary API requests • Improved UI responsiveness • Better user experience 💡 Key takeaway: Use debounce when you want the final action, use throttle when you want continuous control. What scenarios have you used debounce or throttle in? #React #Frontend #WebDevelopment #Performance #JavaScript #NextJS
To view or add a comment, sign in
-
-
React keeps two copies of your UI in memory and swaps them after every commit. That's double buffering. Part 2 goes deeper: priority lanes, where hooks actually live, the three sub-phases of the commit, and why React can pause rendering mid-tree. Read more: https://lnkd.in/ddqhgxHZ #React #Fiber #rendering #reconciliation #JavaScript #WebDev #SoftwareEngineering #BuildInPublic
To view or add a comment, sign in
-
-
Real-World Frontend Problem Every Developer Faces: Unnecessary re-renders can significantly impact performance. The problem arises when components re-render on every parent state change, even if their own props remain unchanged. This is particularly noticeable in large lists or dashboards, leading to visible lag. To address this issue, consider the following solutions: - Wrap pure components with React.memo() to prevent unnecessary re-renders. - Stabilize callbacks using useCallback() to ensure they only change when necessary. - Memoize heavy computations with useMemo() to avoid recalculating values on every render. - For derived state from Redux, utilize createSelector from RTK to prevent selector recalculations. Implementing these strategies can help maintain optimal performance in your applications. The mental model that stuck with me: React.memo stops the re-render. useCallback stops memo from breaking. createSelector stops useSelector from breaking memo. All three work together — remove any one and the others stop working. Have you hit this scenario? Drop your war story below. #ReactJS #FrontendDevelopment #WebPerformance #JavaScript #ReduxToolkit #TechLead #SoftwareEngineering
To view or add a comment, sign in
-
🚀 Improving Frontend Performance with Throttling & Debouncing One key realization while optimizing UI performance 👇 👉 Not all issues are about page load 👉 Many come from how frequently our code runs 🧠 The Problem Events like scroll 📜, resize 📏, and typing ⌨️ can fire hundreds of times per second This leads to: ❌ unnecessary work ❌ busy main thread ❌ poor responsiveness ⚙️ The Solution 🔹 Throttling 👉 Limit execution frequency 👉 e.g., run once every second 🔹 Debouncing 👉 Execute only after user stops 👉 e.g., search after typing stops 🎯 Key Difference 👉 Throttle = steady control 👉 Debounce = wait then act 📊 Why it matters 👉 Less work for browser 🧠 👉 Better responsiveness ⚡ 💡 “Performance is not just faster loading — it’s smarter execution.” #Frontend #JavaScript #WebPerformance #ReactJS #FrontendEngineering
To view or add a comment, sign in
-
Your Next.js Module Federation setup builds without errors. Remotes appear to load. But components render blank. No errors in console. No stack traces. Nothing. The culprit? One missing environment variable: NEXT_PRIVATE_LOCAL_WEBPACK=true Here's what every Next.js MFE host needs: 1. NEXT_PRIVATE_LOCAL_WEBPACK=true — forces local webpack 5 instead of Next.js's bundled copy (no flag = silent Module Federation failure) 2. eager: false for ALL shared deps — eager: true causes SSR hydration mismatch errors 3. isServer ternary for Next.js remotes — picks /ssr/remoteEntry.js on server, /chunks/remoteEntry.js on client 4. output: 'standalone' — ~150MB Docker images instead of 500MB+ 5. ssr: false in next/dynamic — mandatory because remotes attach to window 6. enableImageLoaderFix: true — fixes next/image URLs from remote components 7. Node.js fallbacks (fs: false, stream: false, zlib: false) — browser build crashes without them The full guide walks through a complete production next.config.js with 18 code examples, covers React + Next.js mixed remotes, shared Redux singleton setup, PWA wrapper, and common mistakes. Read the full guide: https://lnkd.in/g6-EjNfE #MicroFrontend #NextJS #ReactJS #ModuleFederation #Webpack5 #WebDev #Frontend #JavaScript #TypeScript #Architecture #DesettiSrinu
To view or add a comment, sign in
-
-
Hydration issues in Next.js can break your UI silently. No errors. Just weird behavior. Here’s why 👇 Server renders HTML. Client re-renders same component. If output differs: ❌ Hydration mismatch Common causes: ✖ Using random values (Math.random, Date.now) ✖ Accessing window during SSR ✖ Conditional rendering differences Result: → UI flicker → Unexpected bugs What works: ✔ Keep server & client output consistent ✔ Move client-only logic inside useEffect ✔ Avoid non-deterministic values Key insight: SSR means your code runs twice. If results differ… Your UI becomes unpredictable. #NextJS #ReactJS #Frontend #SSR #JavaScript #SoftwareEngineering #Debugging #Engineering #WebDevelopment
To view or add a comment, sign in
-
My list UI was behaving weirdly… items were changing unexpectedly 😅 Yes, seriously. At first, I thought it was a state issue. But the problem was something very simple. 💡 I was doing this: {items.map((item, index) => ( Seemed fine… right? ❌ ⚠️ This caused: • Wrong UI updates • Items swapping incorrectly • Hard-to-debug bugs 💡 Then I fixed it: 👉 Used a unique and stable key 🧠 Example: {items.map((item) => ( ✅ Result: • Correct UI updates • No unexpected behavior • Predictable rendering 🔥 What I learned: Keys are not just for React warnings 👉 they control how React updates the UI 💬 Curious: Do you still use index as key… or avoid it? #ReactJS #FrontendDeveloper #JavaScript #CodingTips #WebDevelopment
To view or add a comment, sign in
-
This is subtle but causes real performance issues: ```js // New function reference every render — React remounts the child each time function ParentComponent() { function ChildComponent() { return <div>Child</div>; } return <ChildComponent />; } ``` Every time ParentComponent renders, React sees a brand new component definition. It unmounts and remounts the child — destroying its state and causing unnecessary DOM operations. The fix is simple — define components at the module level: ```js // Stable reference — React correctly reuses the component function ChildComponent() { return <div>Child</div>; } function ParentComponent() { return <ChildComponent />; } ``` This is one of those mistakes that's easy to make and hard to debug when you don't know what to look for. #ReactJS #JavaScript #Frontend #WebDevelopment
To view or add a comment, sign in
-
Most React developers know this rule: “Don’t call hooks inside loops or conditions.” But far fewer understand why. React doesn’t track hooks by variable name or location. It tracks them purely by call order during render. So internally, it’s closer to this mental model: • First useState → slot 0 • Second useState → slot 1 • Third useState → slot 2 Each hook call is mapped based on its position in the sequence. Now imagine this: if (isLoggedIn) { useState(...) } On one render the hook is called, on another it’s not. That shifts the entire sequence. React will still read: • “2nd hook → slot 1” But now it’s actually reading the wrong state. I built a minimal useState implementation (attached) to demonstrate this. You’ll notice: • Hooks are stored in an array • Each call consumes the next index • The index resets on every render • Everything depends on consistent ordering That’s the real rule: It’s not about avoiding conditions It’s about keeping hook calls in the same order every render Once that order changes, state association breaks. #React #JavaScript #Frontend #SoftwareEngineering
To view or add a comment, sign in
-
Explore related topics
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