Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 2, 2022 05:43 pm GMT

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:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To