React native React导航-Redux store的抽屉导航抽屉标签中需要动态文本(翻译)

React native React导航-Redux store的抽屉导航抽屉标签中需要动态文本(翻译),react-native,redux,react-redux,react-navigation,React Native,Redux,React Redux,React Navigation,在react原生应用程序中使用react导航和Redux,我需要在drawerNavigation中动态显示drawerlabel,因为它们随语言而变化。因此,我需要访问存储和道具(例如this.props.locale),但似乎无法使其工作。谢谢你的帮助 我尝试从主父级appNavigator传递screenProps,它确实可以访问存储,但不确定如何在抽屉导航器中访问它们 我真的不想将整个导航存储在Redux中,因为文档暗示这在将来将不受支持,可以避免 我的根目录是AppNavigator,

在react原生应用程序中使用react导航和Redux,我需要在
drawerNavigation
中动态显示
drawerlabel
,因为它们随语言而变化。因此,我需要访问存储和道具(例如
this.props.locale
),但似乎无法使其工作。谢谢你的帮助

我尝试从主父级
appNavigator
传递
screenProps
,它确实可以访问
存储
,但不确定如何在
抽屉导航器中访问它们

我真的不想将整个导航存储在Redux中,因为文档暗示这在将来将不受支持,可以避免

我的根目录是
AppNavigator
,我的
settingsNavigation
文件如下所示

    const BookingsNavigator = createStackNavigator (
    ...
    );

    ...

    const SettingsNavigator = createDrawerNavigator(
        {
            CurrentBookings: {
                screen: BookingsNavigator,
                navigationOptions: {
                    drawerLabel: 'My bookings',
                }
           },
       ...

       },

    );

const AppNavigator = createSwitchNavigator({  
    Bookings: BookingsNavigator,
   // other navigators
});

export default AppNavigator;

对于动态语言更改(在设置屏幕中):

在主屏幕组件中:

static navigationOptions = ({ navigation }) => {
    const { params } = navigation.state;
    return {
      title: i18n.t('home'), // drawer label initialization
      drawerLabel: params && params.DLabel,
      drawerIcon: ({ tintColor }) => (
        <Icon
          type="Entypo"
          name="wallet"
          style={{ fontSize: 24, color: tintColor }}
        />
      ),
    };
  };
静态导航选项=({navigation})=>{
const{params}=navigation.state;
返回{
标题:i18n.t('home'),//抽屉标签初始化
抽屉标签:params&¶ms.DLabel,
抽屉图标:({tintColor})=>(
),
};
};
使用此方法修复它
  onLanguageChange = (value) => {
    this.props.languageChanged(value); // redux action from language picker
    i18n.locale = value === 0 ? 'ru' : 'en'; // set locale manually
  };
static navigationOptions = ({ navigation }) => {
    const { params } = navigation.state;
    return {
      title: i18n.t('home'), // drawer label initialization
      drawerLabel: params && params.DLabel,
      drawerIcon: ({ tintColor }) => (
        <Icon
          type="Entypo"
          name="wallet"
          style={{ fontSize: 24, color: tintColor }}
        />
      ),
    };
  };