<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Manish Kumar</title>
    <description>The latest articles on DEV Community by Manish Kumar (@manish_mk).</description>
    <link>https://dev.to/manish_mk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3320291%2F59f58fe2-b815-4ac9-b9e1-21c8b10f6fe5.jpg</url>
      <title>DEV Community: Manish Kumar</title>
      <link>https://dev.to/manish_mk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/manish_mk"/>
    <language>en</language>
    <item>
      <title>Why Prop Drilling Makes Your React Code Messy</title>
      <dc:creator>Manish Kumar</dc:creator>
      <pubDate>Mon, 07 Jul 2025 17:33:35 +0000</pubDate>
      <link>https://dev.to/manish_mk/why-prop-drilling-makes-your-react-code-messy-393b</link>
      <guid>https://dev.to/manish_mk/why-prop-drilling-makes-your-react-code-messy-393b</guid>
      <description>&lt;p&gt;You start with a simple React app, everything is clean, and then suddenly you're passing props through five components to get some data where it needs to go. It's like being forced to pass a message through people who don't need to hear it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Prop Drilling?
&lt;/h2&gt;

&lt;p&gt;Basically, it's when you pass props through multiple components that don't even need them, just to get the data to a deeply nested child component. Think of it like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Parent has the data
function App() {
  const user = { name: "John", email: "john@example.com" };
  return &amp;lt;Header user={user} /&amp;gt;;
}

// Header doesn't need user data, but passes it down
function Header({ user }) {
  return &amp;lt;Navigation user={user} /&amp;gt;;
}

// Navigation doesn't need it either, but keeps passing
function Navigation({ user }) {
  return &amp;lt;UserProfile user={user} /&amp;gt;;
}

// Finally, someone who actually needs it
function UserProfile({ user }) {
  return &amp;lt;div&amp;gt;{user.name}&amp;lt;/div&amp;gt;;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See the problem? The header and navigation are just middlemen doing nothing useful.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why It's Actually Bad
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Your components become tightly coupled:&lt;/strong&gt; Every component in the chain now depends on props it doesn't care about. Change the user object structure? Good luck updating 4 components.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;It's hard to maintain:&lt;/strong&gt; Want to add a new property? You'll be editing multiple files. Want to remove something? Same story. It's tedious.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Your code becomes harder to read:&lt;/strong&gt; Looking at the Header component, you'd think it cares about user data. But it doesn't. It's just noise.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Testing becomes painful:&lt;/strong&gt; Now you need to mock props in components that don't even use them. Your test setup gets unnecessarily complex.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Better Solutions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Context API for shared state:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const UserContext = createContext();

function App() {
  const user = { name: "John", email: "john@example.com" };
  return (
    &amp;lt;UserContext.Provider value={user}&amp;gt;
      &amp;lt;Header /&amp;gt;
    &amp;lt;/UserContext.Provider&amp;gt;
  );
}

function UserProfile() {
  const user = useContext(UserContext);
  return &amp;lt;div&amp;gt;{user.name}&amp;lt;/div&amp;gt;;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;State management libraries&lt;/strong&gt;: Redux, Zustand, or even simple custom hooks can help you avoid this mess.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Reality Check
&lt;/h2&gt;

&lt;p&gt;I'm not saying never pass props down one level. That's normal. But when you're going 3+ levels deep and components in the middle don't care about the data, that's when you know you need to refactor.&lt;/p&gt;

&lt;p&gt;The goal isn't to avoid props entirely. It's to make your code more maintainable and easier to reason about. Trust me, future you will thank present you for not creating a prop-drilling nightmare.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>redux</category>
      <category>frontend</category>
    </item>
    <item>
      <title>🧠 How to Build a Carousel in ReactJS with Tailwind</title>
      <dc:creator>Manish Kumar</dc:creator>
      <pubDate>Fri, 04 Jul 2025 08:23:41 +0000</pubDate>
      <link>https://dev.to/manish_mk/how-to-build-a-carousel-in-reactjs-with-tailwind-4jch</link>
      <guid>https://dev.to/manish_mk/how-to-build-a-carousel-in-reactjs-with-tailwind-4jch</guid>
      <description>&lt;p&gt;Everyone adds carousels to their websites. Most of the time, people simply install a library like Slick Carousel, add a few props, and move on. However, that approach often adds unnecessary code. In this guide, we’ll learn how to build a clean, lightweight carousel from scratch using React and Tailwind CSS.&lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 Step 1: Create a React + TypeScript project with Vite
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm create vite@latest my-carousel --template react-ts
cd my-carousel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;If you want plain JavaScript, replace react-ts with react.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🎨 Step 2: Install Tailwind CSS
&lt;/h2&gt;

&lt;p&gt;To install Tailwind CSS, follow the instructions at the &lt;a href="https://tailwindcss.com/docs/installation/using-vite" rel="noopener noreferrer"&gt;link&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🖼 Step 3: Load Your Images
&lt;/h2&gt;

&lt;p&gt;Dump your images into &lt;code&gt;public/carouselImages/&lt;/code&gt;. Now set them up:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const carouselImages = [
  "/carouselImages/carousel-1.jpg",
  "/carouselImages/carousel-2.jpg",
  "/carouselImages/carousel-3.jpg",
];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  ⚛️ Step 4: The React Component
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useState, useEffect } from "react";

const carouselImages = [
  "/carouselImages/carousel-1.jpg",
  "/carouselImages/carousel-2.jpg",
  "/carouselImages/carousel-3.jpg",
];

export const Carousel = () =&amp;gt; {
  const [current, setCurrent] = useState(0);

  const prevSlide = () =&amp;gt;
    setCurrent((prev) =&amp;gt; (prev === 0 ? carouselImages.length - 1 : prev - 1));

  const nextSlide = () =&amp;gt;
    setCurrent((prev) =&amp;gt; (prev === carouselImages.length - 1 ? 0 : prev + 1));

  const goToSlide = (index: number) =&amp;gt; setCurrent(index);

  useEffect(() =&amp;gt; {
    const interval = setInterval(nextSlide, 5000);
    return () =&amp;gt; clearInterval(interval);
  }, []);

  return (
    &amp;lt;div className="relative w-full aspect-[16/6] overflow-hidden"&amp;gt;
      {carouselImages.map((image, index) =&amp;gt; (
        &amp;lt;div
          key={index}
          className={`absolute inset-0 transition-opacity duration-700 ease-in-out ${
            index === current ? "opacity-100 z-10" : "opacity-0 z-0"
          }`}
        &amp;gt;
          &amp;lt;img
            src={image}
            alt={`Slide ${index + 1}`}
            className="w-full h-full object-cover"
          /&amp;gt;
        &amp;lt;/div&amp;gt;
      ))}

      {/* Controls */}
      &amp;lt;button onClick={prevSlide} className="absolute top-1/2 left-4 -translate-y-1/2 bg-black/50 text-white p-2 rounded-full z-20"&amp;gt;
        ‹
      &amp;lt;/button&amp;gt;
      &amp;lt;button onClick={nextSlide} className="absolute top-1/2 right-4 -translate-y-1/2 bg-black/50 text-white p-2 rounded-full z-20"&amp;gt;
        ›
      &amp;lt;/button&amp;gt;

      {/* Indicators */}
      &amp;lt;div className="absolute bottom-4 left-1/2 -translate-x-1/2 flex gap-2"&amp;gt;
        {carouselImages.map((_, index) =&amp;gt; (
          &amp;lt;button
            key={index}
            onClick={() =&amp;gt; goToSlide(index)}
            className={`w-3 h-3 rounded-full border border-white ${
              index === current ? "bg-white" : "bg-white/40"
            }`}
          /&amp;gt;
        ))}
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🧠 How Does It Work?
&lt;/h2&gt;

&lt;p&gt;Let’s deconstruct this:&lt;/p&gt;

&lt;h3&gt;
  
  
  🔁 prevSlide
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;setCurrent((prev) =&amp;gt; (prev === 0 ? carouselImages.length - 1 : prev - 1));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you’re on the first slide, wrap to the last. Else, go to the previous. Simple logic, clean loop.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔂 nextSlide
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;setCurrent((prev) =&amp;gt; (prev === carouselImages.length - 1 ? 0 : prev + 1));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you’re on the last slide, wrap to the first. Otherwise, move forward. This is used both on the "›" button and the auto-play logic.&lt;/p&gt;

&lt;h3&gt;
  
  
  🎯 goToSlide
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(index: number) =&amp;gt; setCurrent(index);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This allows direct jumping to a slide. Used in the dot indicators at the bottom.&lt;/p&gt;




&lt;h2&gt;
  
  
  🖼 How Slides Are Actually Rendered
&lt;/h2&gt;

&lt;p&gt;This is where the clean animation happens:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div
  key={index}
  className={`absolute inset-0 transition-opacity duration-700 ease-in-out ${
    index === current ? "opacity-100 z-10" : "opacity-0 z-0"
  }`}
&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All slides are stacked on top of each other.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Only the current index gets opacity-100 and z-10&lt;/li&gt;
&lt;li&gt;Others get opacity-0 and z-0 (hidden behind)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of unmounting and remounting, you simply fade between preloaded images. &lt;/p&gt;




&lt;h2&gt;
  
  
  🕒 Auto-Play
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;useEffect(() =&amp;gt; {
  const interval = setInterval(nextSlide, 5000);
  return () =&amp;gt; clearInterval(interval);
}, []);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every 5 seconds, nextSlide() is triggered.&lt;/p&gt;




&lt;h2&gt;
  
  
  💬 Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Creating a carousel with React and Tailwind helps you understand the basics—state management, rendering, and styling.&lt;/p&gt;

</description>
      <category>react</category>
      <category>tailwindcss</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
