EasyReact Fundamentals📖 Theory Question

What are props and how is prop drilling a problem?

💡

Hint

Props pass data down; drilling = passing through many layers just to reach a deeply nested child

Full Answer

Props are the inputs to a component — passed from parent to child. They are read-only (immutable from the child's perspective).

function Button({ label, onClick, disabled = false }) {
  return ;
}

// Usage

Prop drilling — passing props through intermediate components that don't need them, just so a deep child can access them:

// ❌ Drilling — Middle doesn't need user, just passes it down
function App() {
  const user = { name: 'Alice' };
  return ;
}
function Middle({ user }) {
  return ;
}
function Deep({ user }) {
  return 

{user.name}

; }

Solutions to prop drilling:

  • Context API — broadcast value to any descendant
  • Component composition — lift rendering up, pass JSX as children or slots
  • State management — Zustand, Redux, Jotai for global state
💡 Before reaching for Context, try composition first. Pass children or render props — often eliminates drilling without the overhead of a context.

Practice this in a timed sprint →

5 free questions, no signup required

⚡ Start Sprint