An Interest In:
Web News this Week
- April 27, 2024
- April 26, 2024
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
April 2, 2022 05:43 pm GMT
Original Link: https://dev.to/shrey802/what-are-props-in-react-js--887
What are props in react js ?
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.
Original Link: https://dev.to/shrey802/what-are-props-in-react-js--887
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To