[英]ReferenceError: Can't find variable: loadMoviesLikedDetails (React Native)
I'm new to React Native and I have this project where I have a ReferenceError error, When I get into a page that display all movies the user liked, I have this:我是 React Native 的新手,我有这个项目,我有一个 ReferenceError 错误,当我进入一个显示用户喜欢的所有电影的页面时,我有这个:
ReferenceError: ReferenceError: Can't find variable: loadMoviesLikedDetails
Here's a part of the code of the component:这是组件的一部分代码:
class LikedScreen extends Component {
constructor(props) {
super(props);
this.state = {
moviesLikedDetails: []
};
}
componentDidMount() {
loadMoviesLikedDetails(); <-- SEEMS LIKE THIS CREATES THE ERROR
}
loadMoviesLikedDetails() {
this.props.likedFilms.forEach(async movie => {
const dataDetail = axios.get(
`https://api.themoviedb.org/3/movie/${movie}?api_key=${API_KEY}&language=fr`
);
this.setState({
moviesLikedDetails: [...this.state.moviesLikedDetails, dataDetail.data]
});
});
}
render() {
return (
<View style={styles.container}>
{this.state.moviesLikedDetails.map(movie => (
<View style={{ display: "flex", flex: "wrap", width: "25%" }}>
{movie.id}
</View>
))}
</View>
);
}
}
It looks like the error comes from the execution of the function in the componentDidMount...看起来错误来自 componentDidMount 中 function 的执行...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.