Created
April 3, 2020 13:36
-
-
Save binhtran04/8433bfbe24ee187a6216e18a50c82c75 to your computer and use it in GitHub Desktop.
Movie component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { useMoviesContext } from './MoviesContext'; | |
export const Movie = ({ movie }) => { | |
const { markWatchedMovie } = useMoviesContext(); | |
const handleCheckboxChange = () => { | |
markWatchedMovie(movie.id); | |
}; | |
return ( | |
<article className="Movie"> | |
<h3>{movie.title}</h3> | |
<p>{movie.year}</p> | |
<div className="Movie-actions"> | |
<label className="Movie-watched"> | |
<input type="checkbox" checked={movie.watched} onChange={handleCheckboxChange} /> | |
Watched | |
</label> | |
</div> | |
</article> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment