mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 07:47:04 +00:00
Merge pull request #21670 from pasieronen/react-router-prompt
react-router/react-router-dom: fix typing for getUserConfirmation and Prompt props
This commit is contained in:
Vendored
+2
-2
@@ -27,7 +27,7 @@ export {
|
||||
|
||||
export interface BrowserRouterProps {
|
||||
basename?: string;
|
||||
getUserConfirmation?(): void;
|
||||
getUserConfirmation?: ((message: string, callback: (ok: boolean) => void) => void);
|
||||
forceRefresh?: boolean;
|
||||
keyLength?: number;
|
||||
}
|
||||
@@ -35,7 +35,7 @@ export class BrowserRouter extends React.Component<BrowserRouterProps, any> {}
|
||||
|
||||
export interface HashRouterProps {
|
||||
basename?: string;
|
||||
getUserConfirmation?(): void;
|
||||
getUserConfirmation?: ((message: string, callback: (ok: boolean) => void) => void);
|
||||
hashType?: 'slash' | 'noslash' | 'hashbang';
|
||||
}
|
||||
export class HashRouter extends React.Component<HashRouterProps, any> {}
|
||||
|
||||
Vendored
+2
-2
@@ -34,14 +34,14 @@ export interface RouterChildContext<P> {
|
||||
export interface MemoryRouterProps {
|
||||
initialEntries?: H.LocationDescriptor[];
|
||||
initialIndex?: number;
|
||||
getUserConfirmation?: (() => void);
|
||||
getUserConfirmation?: ((message: string, callback: (ok: boolean) => void) => void);
|
||||
keyLength?: number;
|
||||
}
|
||||
|
||||
export class MemoryRouter extends React.Component<MemoryRouterProps, any> { }
|
||||
|
||||
export interface PromptProps {
|
||||
message: string | ((location: H.Location) => void);
|
||||
message: string | ((location: H.Location) => string | boolean);
|
||||
when?: boolean;
|
||||
}
|
||||
export class Prompt extends React.Component<PromptProps, any> { }
|
||||
|
||||
@@ -12,8 +12,13 @@ const initialRouterEntries = [
|
||||
}
|
||||
];
|
||||
|
||||
const getConfirmation = (message: string, callback: (ok: boolean) => void): void => {
|
||||
const allowTransition = window.confirm(message);
|
||||
callback(allowTransition);
|
||||
};
|
||||
|
||||
const MemoryRouterExample = () => (
|
||||
<MemoryRouter initialEntries={initialRouterEntries} initialIndex={1}>
|
||||
<MemoryRouter initialEntries={initialRouterEntries} initialIndex={1} getUserConfirmation={getConfirmation}>
|
||||
<div>
|
||||
<ul>
|
||||
<li><Link to="/">Home</Link></li>
|
||||
|
||||
Reference in New Issue
Block a user