Im writing a react application and while trying to get all warnings out I found a weird bug...
handleLike = id => {
const movies = [...this.state.movies];
const movie = movies.filter(obj => obj._id === id);
if (movie.map(obj => obj.liked) == "fa fa-heart-o") {
movie.map(obj => (obj.liked = "fa fa-heart"));
this.setState({ movies });
} else {
movie.map(obj => (obj.liked = "fa fa-heart-o"));
this.setState({ movies });
}
In if (movie.map(obj => obj.liked) == "fa fa-heart-o") I dont type check with (===) because it will be falsy for some reason, but obj.liked after Console Logging it with typeof, it says it is a String, so it definetly should be truthy, even after I added ToString() it did not get truthy... I double checked everything, am I missing something ?
Thanks in Advance!