Why won't my nested React components render?

后端 未结 5 585
花落未央
花落未央 2020-12-15 17:44

I\'m having a problem with my React component. The nested children of my component ControlPanel don\'t seem to be rendering. Here is my code:

cl         


        
5条回答
  •  太阳男子
    2020-12-15 18:45

    function FancyBorder(props) {
      return (
        
    {props.children}
    ); } export default function WelcomeDialog() { return (

    Welcome

    Thank you for visiting our spacecraft!

    ); }

    Anything inside theJSX tag gets passed into the FancyBorder component as childrenprop. Since FancyBorder renders {props.children} inside a

    , the passed elements appear in the final output.

    This is what I was looking after, check it out here https://reactjs.org/docs/composition-vs-inheritance.html

提交回复
热议问题