Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Pass Props to a Component Using defaultProps in react

const Banner = ({ name }) => {
  return <div>Hello {name}</div>
}

function App() {
  return (
    <div>
      <Banner />
    </div>
  )
}

Banner.defaultProps = {
  name: "user",
}
export default App
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Pass #Props #Component #Using #defaultProps #react
ADD COMMENT
Topic
Name
6+6 =