2017-05-26 30 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>); 
    } 

這裏是有點我的錯誤消息:

​​

難道我不應該將狀態進入功能參數?

+0

什麼'handleGetDirections'返回? –

回答

1

docsonPress期待一個處理器

它應該是:

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

令人驚歎的謝謝你。這很好。非常感謝您的幫助。 – Freddy

相關問題