我正在尝试结合 react-native、react-navigation-drawer 和 typecsript 并出现此错误:
TypeError:null 不是对象(评估 '_ReanimatedModule.default.configureProps')
环顾四周,我觉得问题可能是没有指定默认路线。 文档说应该有一个initialRoute:
几个选项被传递给底层路由器以修改导航逻辑:
initialRouteName - 初始路由的 routeName。
但是NavigationDrawerConfig 的打字稿绑定不包含这样的字段。这只是打字稿绑定的问题吗?
"dependencies": {
"@types/jest": "^24.0.18",
"@types/react-native": "^0.60.15",
"@types/react-test-renderer": "^16.9.0",
"react": "16.9.0",
"react-native": "0.61.0",
"react-native-gesture-handler": "^1.4.1",
"react-native-navigation": "^2.27.9",
"react-native-reanimated": "^1.2.0",
"react-navigation": "^4.0.9",
"react-navigation-drawer": "^2.2.2",
"react-navigation-stack": "^1.9.0",
"typescript": "^3.6.3"
},
我真的没有从默认的打字稿模板做太多事情:
const RouteConfigs: NavigationRouteConfigMap<NavigationDrawerOptions, NavigationDrawerProp<NavigationRoute>> = {
'home': HomeScreen,
'profile': ProfileScreen
}
const DrawerNavigatorConfig: NavigationDrawerConfig = {
drawerWidth: 100,
drawerPosition: "left"
}
const menu = createDrawerNavigator(RouteConfigs, DrawerNavigatorConfig);
const App = () => {
return (
<>
<StatusBar barStyle="dark-content">OMG</StatusBar>
<SafeAreaView>
<Text>Hello, World</Text>
<Button title="open" onPress={() => {
menu.dispatch(DrawerActions.toggleDrawer())
}}/>
<Text>Did you see the Button?</Text>
</SafeAreaView>
<menu ref={menu}/>
</>
);
};