Prop Drilling in React Components
A common challenge in React development is prop drilling. What it is, the problems it causes as an app grows, and three ways to avoid it.

A common challenge developers encounter in React development is prop drilling. The aim of this article is to look at what it is, the problems it can cause, and how to avoid them.
What is prop drilling?
Prop drilling (sometimes called component chaining) is when data is passed through several layers of the component tree, from parent to child, even though some of the components in between don't need or use it.
Picture a top-level component that fetches data from an API, where the data is needed by a component nested several levels deeper. Every component in between has to accept the data as a prop and pass it along. That passing down through levels that don't use it is prop drilling.
An example
Let's look at a component that shows how many times a button has been clicked, together with the button that counts the clicks.
import { useState } from "react";
function ParentComponent() {
const [clickCount, setClickCount] = useState(0);
function handleButtonClick() {
setClickCount(clickCount + 1);
}
return (
<>
<h1>The button has been clicked {clickCount} times</h1>
<button onClick={handleButtonClick}>Click</button>
</>
);
}Let's break this into smaller components:
import { useState } from "react";
function ParentComponent() {
const [clickCount, setClickCount] = useState(0);
function handleButtonClick() {
setClickCount(clickCount + 1);
}
return <Counter clickCount={clickCount} onClick={handleButtonClick} />;
}
// Child component
function Counter({ clickCount, onClick }) {
return (
<>
<h1>The button has been clicked {clickCount} times</h1>
<button onClick={onClick}>Click</button>
</>
);
}clickCount and handleButtonClick are passed down as props to Counter. Counter can be broken down even further:
// Child component: receives both props but uses neither
function Counter({ clickCount, onClick }) {
return (
<>
<CounterText clickCount={clickCount} />
<CounterButton onClick={onClick} />
</>
);
}
// Grandchild components: the ones that actually use the props
function CounterText({ clickCount }) {
return <h1>The button has been clicked {clickCount} times</h1>;
}
function CounterButton({ onClick }) {
return <button onClick={onClick}>Click</button>;
}This is prop drilling. clickCount and handleButtonClick travel through Counter, which doesn't use them, before they reach the components that do.
What problems can prop drilling cause?
With one level in between, our example doesn't look dangerous. But as your application grows, you may find yourself drilling through many layers of components, and these are the issues you'll face.
Complexity and maintainability
Every component in the chain has to know about props it doesn't care about. Renaming a prop, or adding a new one, means editing every layer in between, and it gets harder to tell where a value actually comes from. That makes the code harder to refactor and to maintain.
Re-renders
When clickCount changes, ParentComponent re-renders, and by default so does every component below it, including the ones in the middle that only forward the props. In a small tree you won't notice. In a large one, a frequently changing value drilled through many layers means a lot of components doing work for nothing, which is exactly the kind of wasted rendering that makes interactions feel slow.
How to avoid prop drilling 🤔
There are several ways to deal with it:
- Composition: pass components as
children(or other props) so the data skips the layers that don't need it. - The Context API: share data with any component below a provider, without passing it through each level.
- State management libraries: libraries such as Redux or Zustand keep state outside the tree, so components read what they need directly.
Composition
Often the simplest fix is to let the parent render the components that need the data and hand them to the middle layer as children:
function ParentComponent() {
const [clickCount, setClickCount] = useState(0);
return (
<Counter>
<CounterText clickCount={clickCount} />
<CounterButton onClick={() => setClickCount(clickCount + 1)} />
</Counter>
);
}
// Counter no longer knows anything about the count
function Counter({ children }) {
return <div className="counter">{children}</div>;
}Counter is now just a layout wrapper. No props pass through it, and adding a new value later doesn't touch it.
Context
When the data is needed in many places, far apart in the tree, use context. Let's refactor the example:
import { createContext } from "react";
export const CountContext = createContext(null);import { useState } from "react";
import { CountContext } from "./CountContext";
import { Counter } from "./Counter";
export function ParentComponent() {
const [clickCount, setClickCount] = useState(0);
function handleButtonClick() {
setClickCount(clickCount + 1);
}
return (
<CountContext value={{ clickCount, handleButtonClick }}>
<Counter />
</CountContext>
);
}import { use } from "react";
import { CountContext } from "./CountContext";
// No props to pass through any more
export function Counter() {
return (
<>
<CounterText />
<CounterButton />
</>
);
}
function CounterText() {
const { clickCount } = use(CountContext);
return <h1>The button has been clicked {clickCount} times</h1>;
}
function CounterButton() {
const { handleButtonClick } = use(CountContext);
return <button onClick={handleButtonClick}>Click</button>;
}In this refactored example, the context provides clickCount and handleButtonClick, and the components that need them read them directly, without the values being passed through every component by hand.
Conclusion
Understanding the impact prop drilling can have on your application should shape how you structure your codebase. Reach for composition first, context when the data is truly shared, and a state library when the state is large or changes often. Used well, these techniques will help you build clean, maintainable and scalable React applications. Good luck!
Geologist turned frontend engineer from Cameroon, based in Ghana. Makes web and mobile apps faster and writes down how. More about me

