ReactJS Props - React Tutorial for Begineers
What is Props in ReactJS ?
- Props are half of what make React components special.
- State is only seen on the inside of component definitions where as Props are defined when components are created by either JSX or by pure JavaScript.
- The main difference between state and props is that props are immutable.
- Props are passed to components through HTML attributes. props stands for properties.
React Props
- React Props are like function arguments in JavaScript and attributes in HTML.
- To send props into a component, use the same syntax as HTML attributes:
Sample Code
Output
Welcome to Wikitechy Tutorial!
Pass Data :
- In props, we can pass data from one component to another, as parameters.
- Note: React Props are read-only! You will get an error if you try to change their value.
Sample Code
Output
Welcome to Wikitechy Tutorial I Learn to React!