Answers for "use props react"

7

pass props in react

/* PASSING THE PROPS to the 'Greeting' component */
const expression = 'Happy';
<Greeting statement='Hello' expression={expression}/> // statement and expression are the props (ie. arguments) we are passing to Greeting component

/* USING THE PROPS in the child component */
class Greeting extends Component {
  render() {
    return <h1>{this.props.statement} I am feeling {this.props.expression} today!</h1>;
  }
}
Posted by: Guest on May-29-2020
0

créer composant react

1. Dans le terminal :
npx create-react-app [ nom dossier]
cd [ nom dossier]
npm start

2.désinstaller package :
npm uninstall -g create-react-app
Posted by: Guest on October-11-2020

Browse Popular Code Answers by Language