I am new to react-native and all its libraries.
I am trying to get my InputText's content across to the next screen using react-redux, but I am not sure how to do it properly. The documentations are too verbose but just explain the theories with nothing practical.
I have 2 screens in my StackNavigator as follows:
const StackNav = StackNavigator({
SignName: { screen: SignNameScreen},
SignBday: { screen: SignBdayScreen}
})
each of the SignNameScreen and SignBdayScreen just has TextInput and I just want to get the user input across the screen.
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>
);
}
}
I tried various methods like creating reducer, export the class using connect etc, but everything just breaks the code. Would anyone point me in the right direction, please?
I have tried numerous sample project from github but they are either unbuildable or unrunnable because of various node problems.. sorry, javascript is my weak point too.
Thanks a lot for your help.
