2017-07-18 6 views
0

私のアプリで日付を計算させたい。これを行うために、私は3つの日付を入力し、ボタンを押すと警告が表示されます。テストするとき、私はバグがあるようです。React Native:予想されるダイナミックタイプ 'string'、型 'object'

<TouchableOpacity onPress={() => {{Alert.alert("Box", <calculator date {this.state.dateInit} />)}}}> 
    <View style={styles.button}> 
     <Text style={styles.buttonText}>Calculer</Text> 
    </View> 
</TouchableOpacity> 

と電卓は、アラートとクラスの両方で、私はthis.props.date.toString()と文字列(this.props.date)で試してみました

class calculator extends Component { 
    render() { 
    return (
     <Text>Le CQE Initial etait le {String(this.props.date)}</Text> 
    ); 
    } 
} 

を参照:私のボタンがありますそして私はまだエラーを取得

TypeError: expected dynamic type string but had type object

しばらくのtoString()または文字列(...)は、文字列としてそれを翻訳している必要があります。

ヘルプのためのThx!

答えて

1

はい、それは確かに右であるあなたはalert機能

Alert.alert("Box", <calculator date {this.state.dateInit} /> 

の第2引数に成分を通過しているが、here

+0

を説明するようalertの第2引数は文字列でなければなりません。代わりに反応ナビゲーションを試してみます。私はまだネイティブに反応して機能の仕組みを理解しなければならない^^。ありがとう! –

関連する問題