1 回答
TA貢獻1865條經驗 獲得超7個贊
if 語句只能返回一個元素,在這種情況下,您嘗試返回兩個<Link>并將<button>其合并為一個使用 a<React.fragment>
例子
const ImageFrame = ({ movieId, movieName, searchWord, image, personMovieId, clickable, clearFavouriteMovie }) => {
return (
<div className = "col-sm-3 mt-5 animated fadeInLeftBig ">
{ clickable ? /* if clickable props is true --> go movie, else go movie again but with personal movie id ! */
<React.fragment>
<Link to={{ pathname:`/movie/${movieId}`, movieName: `${movieName}`, searchWord: `${searchWord}` }}>
<Card className = "card-box image-frame ">
<Card.Img variant="top" src={image} alt="movieImg" />
</Card>
</Link> **!!! I WANT Link component stays here !!!**
{
clearFavouriteMovie && <button
className = "mt-3 btn btn-warning"
onClick = { () => clearFavouriteMovie(movieId)}
> Bu Filmi Sil </button>
}
</React.fragment>
:
<Link to = {{pathname: `/movie/${personMovieId}`}}> {/* Person Known For Movies*/}
<Card className = "bg-dark text-light card-box image-frame " style = {{maxHeight: "500px"}}>
<Card.Img variant="top" src={image} alt="movieImg" />
</Card>
</Link>
}
</div>
)
添加回答
舉報
