What are props in react js? ๐Ÿ‘‡

ยท

1 min read

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 it on the screen.

import React from "react"

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>
    )
}
ย