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 :: javascript prompt yes/no 
Javascript :: discord bot javascript 
Javascript :: javascript get data attribute value 
Javascript :: javascript get black or white text base on color 
Javascript :: editting collection in firebase firestore 
Javascript :: javascript trim string 
Javascript :: How to print somethign to the console with javascript 
Javascript :: react context 
Javascript :: js if string not empty 
Javascript :: get current html file name javascript 
Javascript :: javascript random number not decimal 
Javascript :: get the value of css pseudo properties js 
Javascript :: Javascript Show HTML Elements 
Javascript :: cast object to string javascript 
Javascript :: socket.io cors 
Javascript :: window widht jquery 
Javascript :: how to load link in new window using js 
Javascript :: new line in javascript alert 
Javascript :: react js classname with condition and normal 
Javascript :: loop queryselector 
Javascript :: time complexity javascript 
Javascript :: async useeffect 
Javascript :: momentjs utcoffset 
Javascript :: set file upllaod via javascript to html input 
Javascript :: how to counts date from moment js 
Javascript :: angular date pipe 
Javascript :: CocoaPods could not find compatible versions for pod "React/Core": In Podfile: react-native-fetch-blob (from `../node_modules/react-native-fetch-blob`) was resolved to 0.10.6, which depends on React/Cor 
Javascript :: open link in new tab javascript 
Javascript :: how to write in js 
Javascript :: jquery ajax form submit example 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =