You get a bonus - 1 coin for daily activity. Now you have 1 coin

What is the children prop? in REACT

Practice



Children is a prop (

this.prop.children
) that lets you pass components as data to other components, just like any other prop you use. The component tree placed between a component's opening and closing tags is passed to that component as the
children
prop.

The React API provides several methods for working with this object. They include

React.Children.map
React.Children.forEach
React.Children.count
React.Children.only
React.Children.toArray
A simple use of the children prop looks like the following,

 

const MyDiv = React.createClass({
  render: function() {
    return <div>{this.props.children}</div>
  }
})

ReactDOM.render(
  <MyDiv>
    <span>{'Hello'}</span>
    <span>{'World'}</span>
  </MyDiv>,
  node
)
created: 2020-02-23
updated: 2026-03-10
261



Was this answer useful?
Choose a quick rating so we can improve the next answer for you.
How satisfied are you?


Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Scripting client side JavaScript, jqvery, BackBone"

Terms: Scripting client side JavaScript, jqvery, BackBone