Computer Science, asked by advkulbir9708, 1 year ago

How to import two components and render in reactjs?

Answers

Answered by CoolBro003
0

React will only render the top-level custom components PageTop and PageBottom, as you already found out. The other components (TopPlayers and RecentGames) are nested within those components. What does that mean? React does not just display those nested components because it would not know how to do this. Instead, all rendering must be done by the outer components PageTop and PageBottom. React just passes the nested components to them (PageTop gets TopPlayers, PageBottom gets RecentGames) in this.props.children. Now it is up to the outer components what to do with these nested components. In your example, you would modify the PageTop and PageBottom components to use {this.props.children} to display their nested components in a suitable way.


If you have Some more questions, then contact me at:

     Email: [email protected]

       Youtube: shorturl.at/mnB57

Similar questions