Composition vs Inheritance

2020-08-15  本文已影响0人  bestCindy
function FancyBorder(props) {
  return (
    <div>
      { props.children }
    </div>
  );
}

function WelcomeDialog() {
  return (
    <FancyBorder>
      <h1>
        Welcome
      </h1>
      <p>
        Thank you for visiting out spacecraft!
      </p>
    </FancyBorder>
  )
}
function SplitPane(props) {
  return (
    <div>
      <div>
        { props.left }
      </div>
      <div>
        { props.right }
      </div>
    </div>
  );
}

function App() {
  return (
    <SplitPane left={<Contacts />} right= {<Chat />} />
  );
}
上一篇下一篇

猜你喜欢

热点阅读