Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

Pass Props to a Component Using default parameters in react

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

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

export default App
Comment

PREVIOUS NEXT
Code Example
Javascript :: installing react router dom 
Javascript :: javascript compose function 
Javascript :: jquery grab table row 
Javascript :: generator function fibonacci 
Javascript :: reload page after form submit javascript 
Javascript :: jquery console log 
Javascript :: getserversideprops nextjs 
Javascript :: ternary function javascript 
Javascript :: convert timestamp to time javascript 
Javascript :: angular remove index of array 
Javascript :: clearing cookie in js 
Javascript :: Quoting Strings with Single Quote 
Javascript :: how to make text channels in discord.js 
Javascript :: angular socket.io with token header 
Javascript :: Scroll elementleft using js 
Javascript :: js copy string to clipboard 
Javascript :: javascript round to 7 decimal places 
Javascript :: swapping variables js 
Javascript :: find unique value on array 
Javascript :: create excel sheet in javascript 
Javascript :: how to change css variable in javascript 
Javascript :: $push in mongoose 
Javascript :: typeof array 
Javascript :: React tagInput component 
Javascript :: react router active link css 
Javascript :: promise.all 
Javascript :: javascript print array 
Javascript :: split string into two parts javascript 
Javascript :: expect any function jest 
Javascript :: move element to the top of list javascript 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =