Define children prop in react.js?

Answer

Children is a prop (this.props.children) that allows us to pass components as data to other components, just like any other prop we use. Component tree put between component's opening and closing tag will be passed to that component as children prop.

There are several methods available in the React API to work with this prop.These include React.Children.map, React.Children.forEach, React.Children.count, React.Children.only, React.Children.toArray.

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

ReactDOM.render(
<MyDiv>
<span>{'Hello'}</span>
<span>{'World'}</span>
</MyDiv>,
node
)

All react js Questions

Ask your interview questions on react-js

Write Your comment or Questions if you want the answers on react-js from react-js Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---