Skip to content

Latest commit

 

History

History
13 lines (12 loc) · 602 Bytes

07-props.md

File metadata and controls

13 lines (12 loc) · 602 Bytes

Props

Overview

  • Props are arguments passed into React components. These can also be used to pass data from parent component to child component.
  • React Props are read-only or immutable. React will through an error if we try to change their value.
  • Props are passed to components via HTML attributes. In the Car component, brand is an example of prop.
    <Car brand="Ford" />;
  • The props can be accessed as shown below. this keyword is optional for functional components and required for class components
    <h2>Car Brand is {this.props.brand}</h2>