成功授权时调用回调函数

时间:2017-12-07 22:55:45

标签: javascript ios objective-c reactjs react-native

我是开发具有反应原生的应用程序的新手。我试图通过成功授权转换到下一个应用程序场景。这是我的代码

login = () => {
   firebaseApp.auth().signInWithEmailAndPassword(email, password
   ).then((userData) => {
       var uid = userData.uid;
       localStorage.save('uidKey', uid)
       console.log('uidKey');
       // transition
     }
   ).catch((error) => {
     AlertIOS.alert(
      'Login Failed!',
      'Please try again'
     );
   }); }); }

我知道如何通过按下按钮来触发转换。通过添加这行代码

onPress={() => Actions.root()}>

但我不知道如何从回调中调用此函数。在字符串//过渡

太善良了,帮帮我

1 个答案:

答案 0 :(得分:0)

您应该可以导入操作,然后触发相同的转换:

import { Actions } from 'react-native-router-flux';
...
login = () => {
    firebaseApp.auth().signInWithEmailAndPassword(email, password
    ).then((userData) => {
            var uid = userData.uid;
            localStorage.save('uidKey', uid)
            console.log('uidKey');
            // transition
            Actions.root()
        }
    ).catch((error) => {
        AlertIOS.alert(
            'Login Failed!',
            'Please try again'
        );
    }); }); }