I'm trying to update another component's data depending on which item I click from the list component.
I have a list of "Movies" (Just movie Title). When I click on a movie title from the list, I want another component to show its info (title and description)
Page Component
export default ({ movies }) => {
return (
<div id="home">
<div className="movies">
<List movies={movies}/>
</div>
<div className="">
<Info movies={movies}/>
</div>
</div>
);
}
List Component
export default ({ movies }) => {
return (
<ul>
{movies.map((movie, index) =>
<li key={index}>
{movie.title}
</li>
)}
</ul>
);
}
Info Component
export default ({ movies }) => {
return (
<div className="movie">
<h2>{movies.title}</h2> //Active movie title
<p>{movies.description}</p> //Active movie description
</div>
);
}