0

我正在尝试结合 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}/>
        </>
    );
};
4

1 回答 1

0

可能是链接的问题,在 React-Native 的 0.6 自动链接更新之后经常发生!

转到您的MainApplication.java文件并添加这行代码“ import com.swmansion.reanimated.ReanimatedPackage;

它将导入丢失的包,一切都会正常工作。它应该自动执行此操作(通过自动链接),但由于某些原因它不导入包,所以手动执行!

今天发生在 0.61.4 上,通过按照此处所述导入它解决了!

于 2019-11-18T10:33:07.740 回答