私はreact-nativeとそのすべてのライブラリに不慣れです。
react-reduxを使用してInputTextのコンテンツを次の画面に表示しようとしていますが、正しく行う方法がわかりません。ドキュメントは冗長すぎますが、理論を説明しているだけで、実用的なものは何もありません。
StackNavigatorには次の2つの画面があります。
const StackNav = StackNavigator({
SignName: { screen: SignNameScreen},
SignBday: { screen: SignBdayScreen}
})
それぞれSignNameScreen
とSignBdayScreen
にはTextInputがあり、画面全体でユーザー入力を取得したいだけです。
class SignNameScreen extends Component {
static navigationOptions = {
title: 'Welcome',
};
handleNext() {
Alert.alert("handle button next pressed")
// navigate("SignBday")
}
handleOnPress() {
Alert.alert("handle button login pressed")
}
submitFunc = () => {
const payload = {
email: this.email,
password: this.password
}
console.log(payload)
Alert.alert("hello: " + payload.email)
}
render() {
return (
<View style={{flex: 1, flexDirection: 'column', justifyContent:
'space-around'}}>
<TextInput placeholder="first name"
onChangeText={(text) => this.firstname = text}/>
<TextInput placeholder="last name"
onChangeText={(text) => this.lastname = text}/>
<Button
title="Next"
// onPress={this.handleNext} // this doesnt work, the function cannot access props
onPress={() => {this.props.navigation.navigate("SignBday")}}
/>
</View>
);
}
}
作成reducer
、クラスのエクスポートconnect
など、さまざまなメソッドを試しましたが、すべてがコードを壊してしまいます。誰かが私を正しい方向に向けてくれませんか?
githubから多数のサンプルプロジェクトを試しましたが、さまざまなノードの問題のためにビルドできないか実行できません。申し訳ありませんが、javascriptも私の弱点です。
あなたの助けをどうもありがとう。
このようにナビゲートする
onPress={() => this.props.navigation.navigate('SignBday', { 'Param_Name': 'Param_Value' })}
次に、このような別の画面でパラメータを取得します
const { params } = this.props.navigation.state;
次の画面でパラメータの値を取得するには、
params.Param_Name
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加