Below is the handleLike function I was written
But it is not working to dislike .
HandleLike = (movie) => {
const moviesclone = [...this.state.movies];
const idx = moviesclone.indexOf(movie);
moviesclone[idx] = { ...moviesclone[idx] };
moviesclone[idx].liked = 1 - moviesclone[idx].liked;
this.setState({
movies: moviesclone,
});
};
but changing the 5th line to
moviesclone[idx].liked = !moviesclone[idx].liked;
is working both are same only right ?
And moreover mosh sir created a prop liked={movie.liked} but movie doesnot have attribute liked right? Does that mean we need to add liked attribute for those 9 movies ?
Thanks in advance