第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

導(dǎo)出默認(rèn)不等待我的函數(shù)返回查詢。反應(yīng)原生

導(dǎo)出默認(rèn)不等待我的函數(shù)返回查詢。反應(yīng)原生

Helenr 2022-10-13 16:12:50
我要登錄系統(tǒng)。我的導(dǎo)出默認(rèn)不工作讀取功能。在 AsyncStorage 中讀取函數(shù)查詢 user_id。請(qǐng)幫我 :)應(yīng)用程序.jsvar sendTabs = <TabsScreens />var sendLogin = <LoginScreens />var Read = readStore = async () => {  try {    const value = await AsyncStorage.getItem('user_id');    if (value !== null) {      return 1;    } else {      return 0;    }  } catch (e) {    alert(e);  }}var Welcome;Read().then((response) => {  if (response == 1) {    Welcome = sendTabs  } else {    Welcome = sendLogin;  }});export default () => (Welcome)
查看完整描述

1 回答

?
滄海一幻覺(jué)

TA貢獻(xiàn)1824條經(jīng)驗(yàn) 獲得超5個(gè)贊

您可以定義新組件來(lái)處理此邏輯:


export function WelcomeScreen() {

    const [isLoggedIn, setIsLoggedIn] = React.useState(null); // null | true | false


    React.useEffect(() => {

        void async function getUserId() {

            const id = await AsyncStorage.getItem('user_id');

            setIsLoggedIn(Boolean(id)); // true -> user_id found, false -> no valid user_id found

        }();

    }, []);


    return (userId === null)

        ? <Text>Loading...</Text> // this will show until storage is checked

        : (isLoggedIn) ? <TabsScreens /> : <LoginScreens />; // depending on the value of id from storage you show tabs or login screen

}


查看完整回答
反對(duì) 回復(fù) 2022-10-13
  • 1 回答
  • 0 關(guān)注
  • 101 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)