React Navigation - this.props.navigation.state 未定义

Sau*_*abh 0 react-native react-native-ios react-navigation

使用:“@react-navigation/drawer”:“^5.4.0”,“@react-navigation/native”:“^5.1.4”,

应用程序.js:

    import { createDrawerNavigator } from '@react-navigation/drawer';
    ...
    const Drawer = createDrawerNavigator();
    const DrawerRender = () => {
    return (
      <NavigationContainer>
        <Drawer.Navigator drawerContent={props => <DrawerContent {...props} />}>
          <Drawer.Screen name="Home" component={Home} />
          <Drawer.Screen name="Screen1" component={Screen1} options={{unmountOnBlur: true, gestureEnabled: false}} />
          <Drawer.Screen name="Screen2" component={Screen2} options={{unmountOnBlur: true, gestureEnabled: false}} />
        </Drawer.Navigator>
      </NavigationContainer>
    );}
Run Code Online (Sandbox Code Playgroud)

从屏幕 1:

    navigateToPage = page_id => {
      this.closeCommentScreen();
      this.reopenModal = true;
      this.props.navigation.navigate('Screen2', {'page_id': 'testing'});
    }
Run Code Online (Sandbox Code Playgroud)

在屏幕 2 上:

    export default class Screen2 extends React.Component {

    constructor(props) {
       super(props);
    }
    componentDidMount() {
       let id = this.props.navigation.state.params.page_id
       ...
Run Code Online (Sandbox Code Playgroud)

我尝试打印“this.props.navigation”,它总是返回空字典 {},因此 params 未定义。

我究竟做错了什么?