Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
403 views
in Technique[技术] by (71.8m points)

javascript - 反应本机打字稿-构建JavaScript捆绑错误(React native typescript - buidling javascript bundle error)

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

(如果有需要的任何缺少的信息,请留下评论,我将对其进行编辑。)

Android模拟器中的错误消息:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...