UNPKG

react-router-navigation-confirm

Version:

A collection of components to display a custom confirmation dialog on navigation. More flexible solution to prevent than default react-router 'Prompt'

46 lines (45 loc) 1.82 kB
import * as React from 'react'; import { Action, Location, TransitionPromptHook } from 'history'; import { RouteComponentProps } from 'react-router-dom'; import { HistoryService } from '../services'; import { NavigationConfirmChildren, WhenPropType } from '../types'; interface IProps extends RouteComponentProps { unloadMsg?: string; children: NavigationConfirmChildren; when?: WhenPropType; historyService: HistoryService; } interface IState { isActive: boolean; isOpen: boolean; action: Action; nextLocation: Location; hasError: boolean; } declare class NavigationConfirm extends React.Component<IProps, IState> { static defaultProps: { unloadMsg: string; when: boolean; }; state: IState; unblock: () => void; unlisten: () => void; componentDidMount(): void; componentDidUpdate(prevProps: IProps): void; componentWillUnmount(): void; block: TransitionPromptHook; reblock: () => void; navigate(): void; onBeforeUnload: (event: BeforeUnloadEvent) => string | undefined; render(): {} | null | undefined; private listenUnload; private removeUnload; private onConfirm; private onCancel; private open; private isTheSameLocation; private shouldBlock; private shouldShow; } declare const NavigationConfirmWithRouter: React.ComponentClass<Pick<Pick<IProps, "match" | "children" | "location" | "history" | "staticContext" | "unloadMsg" | "when">, "children" | "unloadMsg" | "when">, any> & import("react-router").WithRouterStatics<React.FunctionComponent<Pick<IProps, "match" | "children" | "location" | "history" | "staticContext" | "unloadMsg" | "when">>>; export { NavigationConfirm, NavigationConfirmWithRouter, IProps as NavigationConfirmProps, IState as NavigationConfirmState, };