React Like Button

Hello guys ,
When I click on the like button to change the icon from full to empty ( vice-versa),
the application gets crashed with this error (TypeError: Cannot read property ‘name’ of undefined
(anonymous function)
C:/Users/ceide/projects/movies-list/src/components/movies.jsx:48
45 | {this.state.movies.map(movie => (
46 |
47 | {movie.title}

48 | {movie.genre.name}
| ^ 49 | {movie.numberInStock}
50 | {movie.dailyRentalRate}
51 |
View compiled
Movies.render
C:/Users/ceide/projects/movies-list/src/components/movies.jsx:44
41 | Delete
42 |
43 |
44 |
| ^ 45 | {this.state.movies.map(movie => (
46 |
47 | {movie.title}</td

Look at line 48:

The movie.genre is undefined for some movie and therefore the TypeError. Make sure that you are setting a movie’s genre.

Hey Sufuian,
thanks for the help.
You know I’m learning. Mosh does not do it so I dont know how to do set it up.

Could you please share the topic and video number you’re on?

Also, can you please share your code where you’re initializing the movies array?