When building a React application, we usually divide our application into small components.
For example, an e-commerce website may have:
Navbar component
Product component
Cart component
Footer component
Sometimes, one component needs to send data to another component.
This is where Props come in.
1. What are Props?
Props stands for Properties .
Props allow us to pass data from one component to another in React.
In simple words, props help components share data with other components.
For example, we can send a username from the App component to the Profile component.
2. How to Pass Props?
Let's understand with a simple example.
App.jsx
function App ( ) { return ( < Profile name = "Lokesh" /> ) ; }
export default App ;
Enter fullscreen mode
Exit fullscreen mode
Here, we are passing name="Lokesh" to the Profile component.
Profile.jsx
function Profile ( props ) { return ( < h1 > Hello , { props .…