Skip to content

Instantly share code, notes, and snippets.

@binhtran04
Created April 3, 2020 13:36
Show Gist options
  • Save binhtran04/8433bfbe24ee187a6216e18a50c82c75 to your computer and use it in GitHub Desktop.
Save binhtran04/8433bfbe24ee187a6216e18a50c82c75 to your computer and use it in GitHub Desktop.
Movie component
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