-
What is prop drilling in React? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Prop drilling in React is when you pass data from a parent component down to deeply nested child components through every level in between even if those middle components don’t need that data themselves, they're just passing it along. As a dev, it's like this: you’ve got a piece of state or a function in a top-level component, but you need it five levels down. Instead of accessing it directly down there, you end up writing prop={something} at every level just to get it to the bottom. It clutters your components and makes things harder to maintain, especially in bigger apps. A common fix is using context, which lets you skip those middle layers and access the data directly where it’s needed. |
Beta Was this translation helpful? Give feedback.
Prop drilling in React is when you pass data from a parent component down to deeply nested child components through every level in between even if those middle components don’t need that data themselves, they're just passing it along.
As a dev, it's like this: you’ve got a piece of state or a function in a top-level component, but you need it five levels down. Instead of accessing it directly down there, you end up writing prop={something} at every level just to get it to the bottom. It clutters your components and makes things harder to maintain, especially in bigger apps.
A common fix is using context, which lets you skip those middle layers and access the data directly where it’s needed.