undefined is not a function (evaluating'_reactNavigation.NavigationActions.reset')

大憨熊 提交于 2019-12-01 03:33:27

reset action is removed from NavigationActions and there is StackActions specific to StackNavigator in v2 of react-navigation.

StackActions is an object containing methods for generating actions specific to stack-based navigators. Its methods expand upon the actions available in NavigationActions.

The following actions are supported:

Reset - Replace current state with a new state

Replace - Replace a route at a given key with another route

Push - Add a route on the top of the stack, and navigate forward to it

Pop - Navigate back to previous routes

PopToTop - Navigate to the top route of the stack, dismissing all other routes

import { StackActions, NavigationActions } from 'react-navigation';

navigateToWalkthrough = () => {
  const navigateAction = StackActions.reset({
    index: 0,
    actions: [NavigationActions.navigate({ routeName: "Walkthrough" })],
  });

  this.props.navigation.dispatch(navigateAction);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!