react native - Send params to DrawerNavigation contentComponent -
basically have stacknavigator
nested in drawernavigator
.
what want use contentcomponent
of drawernavigator
display loged in user avatar , name, image below
just mention im not using redux or that.
i have initializerscrren
reponsible cheking loged user , send right place, login screen or home screen, iam using firebase too, ended this:
constructor(props){ super(props); firebase.auth.listenforauth((evt)=> { var initialroutename = routesids.screen_tutorial; var logeduser = null; if(evt.authenticated) { console.log('user details', evt.user); logeduser = evt.user; initialroutename = routesids.main_drawer; } this.props.navigation.dispatch({type:'reset', actions: [{type:'navigate', routename:initialroutename, params:{user:logeduser}}], index:0}); }); }
my drawernavigator
config this:
var drawerconfig = { drawerwidth: 250, drawerposition: 'left', contentcomponent: props => { console.log('contentcomponent'); console.log(props); return ( <scrollview> <view> <view style={{paddingvertical: 20, paddinghorizontal: 15, backgroundcolor:'#000'}}> <text style={{color:'#fff'}}>avatar, loged in user name</text> </view> <drawerview.items {...props} /> </view> </scrollview> ) }, contentoptions: { activetintcolor: cssdefaults.colorprimary, inactivetintcolor: cssdefaults.textcolor, style: { marginvertical: 0, } } }
thanks!
Comments
Post a Comment