要在登录后和登录前显示不同的抽屉项目

时间:2019-10-15 06:25:20

标签: react-native-navigation

I have a react navigation drawer i want to show some drawer items like profile,wishlist,logout only for login user and some items like about,contact etc..for guest user without login..and show name of login user in drawer 
//main drawer
const MainNavigator=createDrawerNavigator(
 {

// scenennavigator包含所有屏幕         主页:{screen:ScreensNavigator},         愿望清单:拍卖愿望清单,         个人资料:profilenewscreen,          关于:AboutApp,          联系人:Contactcompany,
    },     {         contentComponent :(道具)=>         {           让userData = {};           AsyncStorage.getItem(“ user”)。then(async(user)=> {             console.log(“用户”,用户)             userData = JSON.parse(用户)             //console.log("userid*************",userData.id)
        });             返回(                                                                                       {}                                                                                                                            Alert.alert(                     '登出',                     “您要注销吗?”,                     [                       {text:'Cancel',onPress:()=> {return null}},                       {text:'Confirm',onPress:()=> {                         AsyncStorage.clear();                         props.navigation.navigate('Loginwindow')                       }},                     ],                     {可取消:假}                   )
                }>                   登出                                  

    </SafeAreaView>)
    },
    drawerWidth:300,
}
);
export default createAppContainer(MainNavigator)   ;

0 个答案:

没有答案