我正在尝试使用firebase在我的应用程序中使用电话号码登录,但我遇到了登录过程的问题.我无法使用firebase中的电话号码登录,但如果我使用电话号码注册并重定向到主页,则它正常工作.我使用相同的方法登录,但我得到了问题,TypeError: Cannot read property 'uid' of null但我成功获得所有控制台值.我不知道这里有什么问题.但是这个错误反复出现3次,
这是我的代码:
renderLoginButton() {
if (this.props.loading) {
return (
<Spinner size="large" />
);
}
return (
<Button
style={{ alignSelf: 'flex-start' }}
onPress={this.onLoginBtnClicked.bind(this)}
>
Login
</Button>
);
}
Run Code Online (Sandbox Code Playgroud)
onLoginBtnClicked(){
const { contact, password } = this.props;
const error = Validator('password', password) || Validator('contact', contact);
if (error !== null) {
Alert.alert(error);
} else {
console.log('else');
// this.props.loginUser({ contact, password});
const mobileNo = '+91'+contact;
firebase.auth().signInWithPhoneNumber(mobileNo)
.then(confirmResult =>
console.log(confirmResult),
curr = firebase.auth(),
console.log("curr"+JSON.stringify(curr)),
this.setState({ data: curr}), …Run Code Online (Sandbox Code Playgroud) firebase react-native firebase-authentication firebase-realtime-database
我正在创建过滤器页面屏幕。在此屏幕上,一旦我填写了要过滤数据的所有数据,我将单击“保存”按钮,这会将我重定向到将显示新过滤数据的主页。主页已经显示了常规数据,但是如果我想查看过滤器数据,那么我将从过滤器屏幕中过滤该数据。
但是这里我有问题是我无法重定向到主页。我用于重定向的代码对于我的整个应用程序都是相同的,可以正常运行。我只在重定向到主页时遇到问题,控制台中没有显示错误,但会打印我在函数中编写的消息。而不是什么也没做。
import NavigationService from '../../components/NavigationService';
onSaveClicked() {
console.log('Filter is in progress');
const { navigation } = this.props;
navigation.navigate('home');
const { userprofile } = this.props;
const { type } = userprofile;
NavigationService.navigate('HomeStackScreen1', {type:type});
}
renderButton() {
return (
<Button
style={{ alignItems: 'center' }}
onPress={this.onSaveClicked.bind(this)}
>
Filter
</Button>
);
}
Run Code Online (Sandbox Code Playgroud)
navigationService.js
import { NavigationActions,navigation } from 'react-navigation';
let _navigator;
function setTopLevelNavigator(navigatorRef) {
_navigator = navigatorRef;
}
function navigate(routeName, params) {
_navigator.dispatch(
NavigationActions.navigate({
routeName,
params
})
);
}
function getParams(param){
console.log("param: "+param); …Run Code Online (Sandbox Code Playgroud)