我的主要路线有一个 DrawerNavigator 配置
const App = DrawerNavigator(DrawerRoutes, {
initialRouteName: 'Main',
contentComponent: ({ navigation }) => <DrawerMenu navigation={navigation} routes={DrawerRoutes} />,
mode: Platform.OS === 'ios' ? 'modal' : 'card',
drawerWidth: Dimensions.get('window').width - (Platform.OS === 'android' ? 56 : 64),
drawerPosition: 'left',
})
我想改变抽屉位置属性取决于应用程序的当前语言。
我已经尝试连接到 redux 但没有成功,因为它会抛出无效 React 元素的错误。
如何即时更改抽屉导航器属性?
我最终得到了一个不太优雅的解决方案。
我复制了react-navigation的DrawerNavigator并将其添加到我的项目中。
无法正常工作的导入已修复为指向原始的反应导航项目,并且我在 DrawerView 组件上的 DrawerPosition 属性上实现了应用程序逻辑
const Drawer = I18nReader()(
({ i18n, ...restProps }) =>
<DrawerView
{...restProps}
useNativeAnimations={useNativeAnimations}
drawerWidth={drawerWidth}
contentComponent={contentComponent}
contentOptions={contentOptions}
drawerPosition={i18n.rtl ? 'right' : 'left'}
/>
)
const navigator = createNavigator(
drawerRouter,
routeConfigs,
config,
NavigatorTypes.DRAWER
)(Drawer)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)