// @flow

import { NavigationActions } from 'react-navigation';

import { dispatch } from '../redux/redux-setup';
import { ActionResultModalRouteName } from './route-names';

function displayActionResultModal(message: string) {
  dispatch({
    // We do this for Flow
    ...NavigationActions.navigate({
      routeName: ActionResultModalRouteName,
      params: { message },
    }),
  });
}

export { displayActionResultModal };

// @flow

import { NavigationActions } from 'react-navigation';
import invariant from 'invariant';

import { ActionResultModalRouteName } from './route-names';
import { getGlobalNavContext } from './icky-global';

function displayActionResultModal(message: string) {
  const navContext = getGlobalNavContext();
  invariant(navContext, 'navContext should be set in displayActionResultModal');
  navContext.dispatch(
    NavigationActions.navigate({
      routeName: ActionResultModalRouteName,
      params: { message },
    }),
  );
}

export { displayActionResultModal };

Use global NavContext for displayActionResultModal