2017-12-11 25 views
0

ではないと私は、このエラーを持っている:_this6.functionは、私が反応し、ネイティブに動作する機能

callGeocodage(adress) { 
console.log(adress); 
    } 

    renderAd(item, index) { 
    return (
     <Card style={{ elevation: 3, width: Dimensions.get('window').width}}> 
     <CardItem cardBody> 
      <TouchableOpacity onPress={() => {this.callGeocodage(item.adress)}}> 
      <IconFontAwesome name={ICON_SEARCH} /> 
      </TouchableOpacity> 
      <Text>{item.adress} </Text> 
     </CardItem> 
     </Card> 
    ); 
    } 

_this6.callGeocodageが機能

私のコードではありません

誰かがなぜ知っていますか?

+0

ので 'このようなコンストラクタで、あなたの' callGeocodage'機能をバインドしよう.callGeocodage = this.callGeocodage.bind(this); ' –

+0

関数は次のように記述します。' callGeocodage =(adress)=> { console.log(address); }; ' –

+0

' renderAd'がどのように呼び出されるのかを教えてください – Bergi

答えて

1

あなたはコンストラクタでrenderAdにこれをバインドする必要があります。

constructor(props){ 
    super(props); 
    this.renderAd = this.renderAd.bind(this); 
} 

または矢印FUNCとしてそれを使用する:

const renderAd = (item, index) => { 
+0

私はrenderAd =(item、index)=> {しようとしています。 –

関連する問題