This content originally appeared on DEV Community and was authored by Shreyash Pingle
Props are basically arguments passed in a react component and with the help of props you can pass the data instead of hard coding it and rendering on the screen.
export default function Card(props) {
return (
<div className="card">
<img src={`../images/${props.img}`} className="card--image" />
<div className="card--stats">
<img src="../images/star.png" className="card--star" />
<span>{props.rating}</span>
<span className="gray">({props.reviewCount}) • </span>
<span className="gray">{props.country}</span>
</div>
<p>{props.title}</p>
<p><span className="bold">From ${props.price}</span> / person</p>
</div>
)
}
The above is an example of a prop with some property names such as image, rating, etc.
This content originally appeared on DEV Community and was authored by Shreyash Pingle

Shreyash Pingle | Sciencx (2022-04-02T17:43:39+00:00) What are props in react js ?. Retrieved from https://www.scien.cx/2022/04/02/what-are-props-in-react-js/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.