所以这是我第一次使用堆栈溢出,如果这看起来不好,我感到抱歉!我在设置React Native App Firebase身份验证时遇到问题。我希望我的用户先登录然后再进入下一个屏幕。我的问题是我遇到了Firebase无法进行身份验证的麻烦。我一直在查看google firebase文档和其他堆栈问题,但没有一个帮助我。
这是我的代码:
//React and CSS
import * as React from 'react';
import {View, Text, StyleSheet, TextInput} from 'react-native';
import LoginButton from '../components/LoginButton';
import ForgotPassButton from '../components/ForgotPassButton';
//Help screen after login
import Help from '../pages/Help';
// Login Function
import firebase from '@react-native-firebase/auth';
class LoginForum extends React.Component {
async _logMeIn() {
console.log('hi');
firebase
.auth()
.signInWithEmailAndPassword('Janunda@ivytech.edu', 'Pa$$w0rd')
.then(() => this.props.navigation.navigate('Help'))
.catch(error => this.setState({errorMessage: error.message}));
}
render() {
return (
<View style={styles.backgroundColor}>
<TextInput
style={styles.userInput}
placeholder="Email"
placeholderTextColor="rgba(255,255,255,0.8)"
returnKeyType="next"
/>
<TextInput
style={styles.userInput}
placeholder="Password"
placeholderTextColor="rgba(255,255,255,0.8)"
/>
<LoginButton
buttonName="Login"
customTouchableStyle={{
width: '75%',
height: '50%',
}}
customViewStyle={{backgroundColor: '#FFAB40'}}
onPress={this._logMeIn}
/>
<ForgotPassButton
buttonName="Forgot Password"
customTouchableStyle={{
width: '10%',
height: '40%',
}}
customViewStyle={{backgroundColor: '#EB3461'}}
// onPress={userLogin.handleLogin}
/>
</View>
);
}
}
const styles = StyleSheet.create({
userInput: {
width: '75%',
padding: 10,
marginBottom: 10,
height: 50,
paddingHorizontal: 10,
marginTop: 58,
color: '#FFFFFF',
flexGrow: 1,
fontSize: 25,
},
loginButton: {
height: 70,
paddingVertical: 20,
backgroundColor: 'rgba(255,255,0,1.8)',
},
loginText: {
fontWeight: '700',
textAlign: 'center',
color: '#FFFFFF',
fontSize: 20,
},
forgotPassword: {
fontWeight: '700',
textAlign: 'center',
color: '#FFFFFF',
padding: 30,
fontSize: 20,
},
});
export default LoginForum;
错误:
Possible Unhandled Promise Rejection (id: 6):
TypeError: _auth.default.auth is not a function. (In '_auth.default.auth()', '_auth.default.auth' is undefined)
_logMeIn$@http://localhost:8081/forum/LoginForum.bundle?platform=ios&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true:65:35
tryCatch@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:30556:23
invoke@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:30732:32
tryCatch@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:30556:23
invoke@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:30632:30
http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:30662:19
tryCallTwo@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:3329:9
doResolve@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:3493:25
Promise@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:3352:14
callInvokeWithMethodAndArg@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:30661:33
enqueue@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:30666:157
http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:30683:69
_logMeIn@http://localhost:8081/forum/LoginForum.bundle?platform=ios&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true:59:42
onPress@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:57595:34
_performTransitionSideEffects@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:57151:22
_receiveSignal@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:57089:45
onResponderRelease@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:57007:34
invokeGuardedCallbackImpl@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:12754:21
invokeGuardedCallback@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:12848:42
invokeGuardedCallbackAndCatchFirstError@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:12852:36
executeDispatch@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:12957:48
executeDispatchesInOrder@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:12977:26
executeDispatchesAndRelease@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:13078:35
forEach@[native code]
forEachAccumulated@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:13068:22
runEventsInBatch@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:13102:27
runExtractedPluginEventsInBatch@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:13186:25
http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:14226:42
batchedUpdates$1@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:26457:20
batchedUpdates@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:14164:36
_receiveRootNodeIDEvent@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:14225:23
receiveTouches@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:14255:34
__callFunction@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2755:49
http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2477:31
__guard@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2709:15
callFunctionReturnFlushedQueue@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2476:21
callFunctionReturnFlushedQueue@[native code]