Оператор if может возвращать только один элемент, в этом случае вы пытаетесь вернуть два <Link>
и <button>
, чтобы сделать это одним, используя <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>
)