function submit(email, password) {
FirebaseAPI.createUser(email, password)
}
export default function LoginScreen() {
const [email, onChangeText] = React.useState('Enter Email');
const [password, onChangeText2] = React.useState('Enter Password');
const componentDidMount = () => {
this.watchAuthState(this.props.navigation)
}
const watchAuthState =(navigation) => {
firebase.auth().onAuthStateChanged(function(user) {
console.log('onauthStateChanged', user)
if (user) {
this.props.navigation.navigate('Main');
// this.props.navigation.navigate('App');
}
});
}
return (
<KeyboardAvoidingView style={styles.wrapper} behavior="padding">
<View style={styles.scrollViewWrapper}>
<ScrollView style={styles.scrollView}>
<Text style={styles.loginHeader}>Creat an Account </Text>
<TextInput
style={{ height: 40, borderColor: 'gray', borderWidth: 1 }}
onChangeText={text => onChangeText(text)}
value={email}
/>
<TextInput
style={{ height: 40, borderColor: 'gray', borderWidth: 1 }}
onChangeText={text => onChangeText2(text)}
value={password}
/>
<TouchableOpacity
style={{marginTop: '5%'}}
onPress= {(submit(email,password))}>
<View>
<Text>Submit</Text>
</View>
</TouchableOpacity>
</ScrollView>
</View>
</KeyboardAvoidingView>
);
}
Firebase可以正常使用此功能,但是我有一个问题,即使我输入说john@gmail.com密码sfjkskfs等,即使在我按下“提交”按钮之前,它也会自动将其发送到Firebase。
任何帮助都会很棒!
答案 0 :(得分:3)
我认为您在onPress
函数中使用了错误的代码。您应该对此部分使用onPress函数
onPress = {() => this.submit(email,password)}