2017-05-26 4 views
0

メソッドを呼び出してパラメータを渡すときにエラーが発生し、ボタンの背後にあるアクションが自動的に実行されます。ここでReact Native:処理されていない約束の拒否、無効な引数の提供

は私のレンダリングです:

render() { 
    return (<View style={styles.container}> 
     <Card> 
     <CardSection> 
      <Button 
      accessibilityLabel='Click this button to find somewhere you and your friend can meet' 
      onPress={this.handleGetDirections(this.state.lat1, this.state.lng1, this.state.lat2, this.state.lng2)} 
      > 
      Get Directions 
      </Button> 
     </CardSection> 
     </Card> 
    </View>); 
    } 

ここに私のエラーメッセージのビットは次のとおりです。

​​

私はパラメータとして関数に状態を渡すことになっていないだろうか? docsから

+0

'返しhandleGetDirections'んでしょうか? –

答えて

1

onPressハンドラ

を期待していることは、次のようになります。

onPress={()=>this.handleGetDirections(this.state.lat1, this.state.lng1, this.state.lat2, this.state.lng2)} 
+0

すばらしいありがとう。これは素晴らしいです。本当に助けに感謝します。 – Freddy

関連する問題