簡體   English   中英

成功授權后調用回調函數

[英]Calling the callback function on successful authorization

我是使用反應式本機開發應用程序的新手。 我正在嘗試通過成功的授權過渡到下一個應用程序場景。 這是我的代碼

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()}>

但是我不知道如何從回調中調用此函數。 在字符串中// transition

這么仁慈,幫幫我

您應該能夠導入動作,然后觸發相同的過渡:

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'
        );
    }); }); }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM