Manon.icu

I'm here to make you a better developer by teaching you everything I know about building for the web.

Published 2021-04-18

React Children Props

props 接受一个 children 参数,这个参数可以是一个字符串,也可以是一个数组,数组中的每一项都是一个字符串

function App() {
  return (
    <User>
      <h1>Hello, John Doe!</h1>
    </User>
  )
}

function User({children}) {
  return children // Hello, John Doe!
}

Comments

No Comments!