2017-09-19 19 views
-1

アプリには「ホーム」と呼ばれるページがあり、これはホーム用のコードです。アプリが実行されると、 がクラッシュします。考えられるエラーを見つけて、このソースコードの問題を解決してください。 注:APIの応答は200で、データに間違いがないものとします。ネイティブアプリのクラッシュに反応する

import React, { Component, } from ‘react’ ; 
import { View, Text } from ‘react-native’ ; 
import PropTypes from 'prop-types' ; 
import Api from ‘../../utils/api’ ; 
import * as styles from ‘../../styles/styles’ ; 

class HomeView extends Component { 
    constructor (props) { 
     super(props); 
     this .state = { data: null }; 
    } 

    render() { 
     Api. fetchData (this .props.name, this .props.phoneNumber) 
      . then (response => { 
       self .setState({data: response.data}); 
       self.props.onUpdate({ data: response.data}); 
     }); 
     return (
      < View style={style.container}> 
       < Text style={style.row}> 
        {this.state.data.fullName} 
       </ Text > 
       < Text style={style.row}> 
        {this.state.data.phoneNumber} 
       </ Text > 
       < Text style={style.row}> 
        {this.state.data.maritalStatus} 
       </ Text > 
      </ View > 
     ) 
    } 
} 

const style = styles.homeView; 
HomeView. propTypes = { 
    name: PropTypes .string, 
    phoneNumber: PropTypes .string, 
} 
HomeView. defaultProps = { 
    name: 'Aliens', 
    phoneNumber: '+999999999', 
} 

答えて

0

Api. fetchData

Api.fetchData (this.props.name, this.props.phoneNumber) 
    .then (response => { 
    self.setState({data: response.data}); 
    self.props.onUpdate({ data: response.data}); 
}); 
にスペースを削除してください
関連する問題