What is prop drilling, and how can you avoid it?

React JSX, components and props · Freshers and experienced

Model answer

Prop drilling means passing a prop through many layers of components that do not use it, just to reach a deep child. It makes code harder to change.

Options: use composition (pass the child component or children from above), put the data in Context, or use a state library. Do not reach for Context too early: sometimes restructuring the components is the simplest fix.

Learn this topic

React Components and Props Explained with Examples in the course React.js Full Course: Beginner to Advanced.

Sign in to add your own answer.

More questions