Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native 将参数发送到抽屉活动内容组件_React Native_React Navigation - Fatal编程技术网

React native 将参数发送到抽屉活动内容组件

React native 将参数发送到抽屉活动内容组件,react-native,react-navigation,React Native,React Navigation,基本上我有一个StackNavigator嵌套在DrawerNavigator中 我想要的是使用DrawerNavigator的contentComponent来显示登录的用户头像和名称,如下图所示 只是说我没有使用redux或类似的东西 我有一个InitializerScrren,负责检查登录用户并将其发送到正确的位置,登录屏幕或主屏幕,iam也使用firebase,因此我最终得出以下结论: constructor(props){ super(props); firebas

基本上我有一个
StackNavigator
嵌套在
DrawerNavigator

我想要的是使用
DrawerNavigator
contentComponent
来显示登录的用户头像和名称,如下图所示

只是说我没有使用redux或类似的东西

我有一个
InitializerScrren
,负责检查登录用户并将其发送到正确的位置,登录屏幕或主屏幕,iam也使用firebase,因此我最终得出以下结论:

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});
    });
}
我的
DrawerNavigator
配置如下:

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,
        }
    }
}
var-drawerConfig={
抽屉宽度:250,
抽屉位置:'左',
contentComponent:props=>{
log('contentComponent');
控制台日志(道具);
返回(
头像,登录用户名
)
},
内容选项:{
activeTintColor:cssDefaults.colorPrimary,
InactiveIntColor:cssDefaults.textColor,
风格:{
结果:0,
}
}
}

谢谢

如果某个redux解决方案对您有效,请告诉我。忘了提及,我没有使用reduxany解决方案,因为?@AlainIb nope,但是这个项目现在被放弃了。学习redux或mobx做这件事更好更容易。所以当我回到它时,它会重构一些东西。