Skip to main content

Posts

Showing posts with the label TypeScript

Tailwind v4 Architecture: Scalable Components with CVA and Slots

  Modern frontend architecture has shifted. We moved from global CSS files to CSS-in-JS, and finally to utility-first frameworks like Tailwind. However, as applications scale, a new bottleneck emerges: the "Template Literal Soup." Developers often find themselves concatenating ternary operators inside giant strings. This approach is brittle, hard to read, and difficult to type. When you add Tailwind v4’s new engine—which emphasizes native CSS variables and composition—you need a robust strategy to handle component variations. This article details a production-grade architecture for managing complex, multi-part components using Tailwind CSS, TypeScript, and Class Variance Authority (CVA). The Engineering Problem: Specificity and String Soup In a raw Tailwind implementation, dynamic styling usually looks like this: // ❌ The Anti-Pattern <div className={`flex rounded-md border ${ hasError ? 'border-red-500 bg-red-50' : 'border-gray-300' } ${ isDisabled ? ...

Expo Router: Handling Nested Deep Links with Dynamic Segments

  One of the most frustrating moments in React Native development is perfecting your navigation logic, only to have it break completely when accessed via a deep link. The scenario is all too common: You have a standard navigation flow that works perfectly within the app. You click a user, you go to their details, then to their settings. The path looks like  /user/123/settings . However, when you trigger  myapp://user/123/settings  externally, one of two things happens: You get a  404 Unmatched Route  screen. The screen renders, but your dynamic ID ( 123 ) comes back as  undefined , crashing your API calls. If you are struggling with  useLocalSearchParams  returning empty objects during deep linking or navigation state hydration issues in deeply nested stacks, this guide is the definitive fix. The Root Cause: Parameter Scoping and Hydration To fix this, you must understand how Expo Router (built on top of React Navigation) handles URL parsing ...