DEV Community

SATHISHKUMAR R
SATHISHKUMAR R

Posted on

What is Props Children in React?

In React, props.children is a special prop used to access the content placed between the opening and closing tags of a component.

In simple words, it allows us to pass content inside a reusable component.

function Welcome(props) {
return (


{props.children}



);
}

function App() {
return (

Hello React!

);
}

export default App;

output;
Hello React!

Example with multiple children:

function Card(props) {
return (


{props.children}

);
}

function App() {
return (

My Profile


I am learning React.


View Profile

);
}

export default App;

Here, props.children receives all three elements:

Props vs Props.children:

 Props                                 Props.children
Enter fullscreen mode Exit fullscreen mode

Used to pass data to components. Used to pass nested content.
Can pass name, age, etc. Can pass text, JSX, or components.
Access using props.name. Access using props.children.

Top comments (0)