0

我只想在登錄成功時導航到新屏幕,如果條件內使用了{Actions.HomeScreen},但它沒有做任何事情。如何根據RNRF中的條件進行導航原生

這裏是代碼:

async login() { 
const res = await api.getLoginResult(); 
const status= res.status; 
console.log('log'+status); 
if(status==='success'){ 
    {Actions.HomeScreen;} 
} 

} 

回答

1

你忘了實際調用的功能,它應該是:

async login() { 
    const res = await api.getLoginResult(); 
    const status = res.status; 
    console.log('log' + status); 
    if(status === 'success') { 
    Actions.HomeScreen(); // Note the parens() 
    } 
}