TypeError: undefined is not an o

2022-03-23  本文已影响0人  sunny635533

使用react-navigation库遇到:
TypeError: undefined is not an object (evaluating '_this.view._component.measureInWindow')

找了很久没找到原因,上网查才知道:必须要设置第一个页面默认的navigationOptions = { header: null };

const MyApp = createStackNavigator(
                {
                    PrivacyPolicy: {
                        screen: PrivacyPolicyPage,
                        navigationOptions: ({ navigation }) => ({
                            header: null
                        })
                    },
                    HomeGroup: {
                        screen: HomeGroupPage,
                        navigationOptions: ({ navigation }) => ({
                            header: null
                        })
                    },
                    HomeArea: {
                        screen: HomeAreaPage
                    },
                    HomeManager: {
                        screen: HomeManagerPage
                    },
                    HomeStaff: {
                        screen: HomeStaffPage
                    },
                    Settings: {
                        screen: DrawerPage
                    },
                },
)

发现如果使用drawer还是报错,继续参考:https://github.com/react-navigation/react-native-safe-area-view/issues/118

image.png

亲测,可以了!

上一篇下一篇

猜你喜欢

热点阅读