React Native Navigation-'无法读取未定义的属性'dispatch'

时间:2018-10-28 05:22:37

标签: reactjs react-native navigation react-router react-navigation

尝试导航到另一个屏幕,但遇到问题。代码如下:

Routes.js

import { Drawer } from './Drawer';
import { ItemDetailsScreen } from '../screens/ItemDetailsScreen';
enter code here
export const App = createStackNavigator(
    {
        Drawer: { 
            screen: Drawer
        },

        ItemDetails: {
            screen: ItemDetailsScreen
        }
    },
    {
        initialRouteName: "Drawer",
        headerMode: "none"
    }
)

Drawer.js

export const Drawer = createDrawerNavigator(
    {
        Home: { screen: ItemListScreen }
    },
    {
        navigationOptions: () => ({
            drawerLockMode: 'locked-closed'
        }) 
        initialRouteName: "Home",
        drawerPosition: 'left',
        contentComponent: props => <SideBar {...props} />
    }
)

通过调用以下方法尝试导航“ ItemDetailsS​​creen”时,它会向我显示错误

onItemPress(item) {
    const navigateAction = NavigationActions.navigate({
            routeName: 'ItemDetailsScreen',
            params: {item: item}
        })
        this.props.navigation.dispatch(navigateAction)
    }

错误是:

  

无法读取未定义的属性“ dispatch”

0 个答案:

没有答案