I'm very new to react and i encountered this problem where i get this error message:
(我是新来的人,我在收到此错误消息时遇到了这个问题:)
but i can't seem to find what the problem means.
(但我似乎无法找到问题所在。)
From what i understand the problem lives in the MovieFocusCard component but i don't know where the fault is situated. (据我了解,问题存在于MovieFocusCard组件中,但我不知道故障位于何处。)
can anyone explain me what this error means and how to fix it?
(谁能解释这个错误的含义以及如何解决?)
If there's any missing information needed leave a comment and i'll edit it in. thanks in advance (如果有需要的任何缺少的信息,请留下评论,我将对其进行编辑。)
MovieFocusCard code:
(MovieFocus卡代码:)
import React, { Component } from "react";
import { View, Text, Image } from "react-native";
import MovieDetails from "../Types/MovieDetails";
import { NavigationInjectedProps, withNavigation } from "react-navigation";
type MovieFocusCardProps = {};
type MovieFocusCardState = {
movieDetails: MovieDetails;
loaded: boolean;
};
class MovieFocusCard extends Component<
NavigationInjectedProps,
MovieFocusCardState
> {
constructor(props: NavigationInjectedProps) {
super(props);
this.state = {
movieDetails: null,
loaded: false
};
}
componentDidMount() {
this.GetMovieDetails(this.props.navigation.getParam("movieId", 0));
}
GetMovieDetails(id: number) {
let url: string = "https://api.themoviedb.org/3/movie/";
let apiKey: string = "?api_key=396734bc8915c8d1569cb4ff49b59c56";
fetch(url + id + apiKey)
.then(result => result.json())
.then(data =>
this.setState({
movieDetails: data,
loaded: true
})
)
.catch(console.log);
}
render() {
let posterUrl: string =
"https://image.tmdb.org/t/p/w200" + this.state.movieDetails.poster_path;
// let rdate = new Date(
// this.state.movieDetails.release_date
// ).toLocaleDateString();
let element;
this.state.loaded
? (element = (
<View>
<Text>{this.state.movieDetails.title}</Text>
<Image source={{ uri: posterUrl }} />
<Text>Summary: {this.state.movieDetails.overview}</Text>
<Text>Duration: {this.state.movieDetails.runtime} min</Text>
</View>
))
: (element = <Text>Loading</Text>);
return { element };
}
}
export default MovieFocusCard;
ask by ruben translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…