Need Assistance?

support@tutorialshub.in

Props and Data Flow

Passing Functions and Children as Props

React.js Free Lesson
5 min read
ADVERTISEMENT

Passing Functions to Children

A parent can pass a function as a prop. This allows a child component to notify the parent that an action happened.

This pattern is useful when a button inside a child needs to update data owned by the parent.

The children Prop

Anything placed between a component opening and closing tag is available through the special children prop. This is useful for creating wrapper and layout components.

Practical Pattern

Keep important application state in the component that needs to own it, then pass data and callbacks to children that need access to it.

ADVERTISEMENT