Skip to content

Instantly share code, notes, and snippets.

@olee

olee/index.d.ts

Created Dec 20, 2016
Embed
What would you like to do?
react-router@v4/index.d.ts
import * as React from "react";
interface Location {
pathname: string;
query?: any;
state?: any;
}
interface RenderProps {
pattern: string;
pathname: string;
isExact: boolean;
location: Location;
params: any;
}
interface RenderCallback {
(props: RenderProps): JSX.Element;
}
interface MatchProps {
/**
* Any valid URL pattern that `path-to-regexp` understands.
*/
pattern: string;
/**
* When true, will only match if the pattern matches the location.pathname exactly.
*/
exactly?: boolean;
/**
* If you don’t want to match the location on context, you can pass a location as a prop instead.
*/
location?: Location;
component?: JSX.ElementClass;
render?: RenderCallback;
children?: RenderCallback;
}
interface MissProps {
component?: JSX.ElementClass;
render?: RenderCallback;
}
interface LinkProps {
to: string | Location;
activeStyle?: any;
activeClassName?: string;
activeOnlyWhenExact?: boolean;
isActive?: (location: Location) => boolean;
location?: Location;
}
interface LinkChildrenProps {
isActive: boolean;
location: Location;
href: string;
onClick: Function;
transition: Function;
}
interface LinkChildrenCallback {
(props: LinkChildrenProps): JSX.Element;
}
interface RedirectProps {
to: string | Location;
}
interface NavigationPromptProps {
message: string | ((location: Location) => string);
when?: boolean;
}
interface StaticRouterProps {
}
interface BrowserRouterProps {
basename?: string;
}
interface HashRouterProps {
/**
* The base URL for all locations.
* If your app is served from a sub-directory on your server,
* you’ll want to set this to the sub-directory.
*/
basename?: string;
/**
* "slash": default - Creates urls like #/ and #/foo/bar
* "noslash" - Creates urls like # and #foo/bar
* "hashbang" - Creates extra ugly urls like #!/ and #!/foo/bar
*/
hashType?: "slash" | "noshlash" | "hashbang";
}
interface MemoryRouterProps {
initialEntries?: Location[];
initialIndex?: number;
}
interface ServerRouterProps {
/**
* The location the server received, probably req.url on a node server.
*/
location: string;
/**
* An object returned from createServerRenderContext.
* It keeps the rendering result so you know which status code to send and
* if you need to perform a second pass render to render
* the <Miss> components in your app.
*/
context?: any;
}
/**
* Renders UI when a pattern matches a location.
*/
export class Match extends React.Component<MatchProps, {}> { }
/**
* When no Match components match the current location, then a sibling Miss will render.
*/
export class Miss extends React.Component<MissProps, {}> { }
/**
* Provides declarative, accessible navigation around your application.
*/
export class Link extends React.Component<LinkProps, {}> { }
/**
* Rendering a Redirect will navigate to a new location and add the previous location onto the next location state.
*/
export class Redirect extends React.Component<RedirectProps, {}> { }
/**
* When your application enters a state that should prevent the user from
* navigating away (like a form is half-filled out), render a NavigationPrompt.
*/
export class NavigationPrompt extends React.Component<NavigationPromptProps, {}> { }
export class StaticRouter extends React.Component<StaticRouterProps, {}> { }
export class BrowserRouter extends React.Component<BrowserRouterProps, {}> { }
export class HashRouter extends React.Component<HashRouterProps, {}> { }
export class MemoryRouter extends React.Component<MemoryRouterProps, {}> { }
export class ServerRouter extends React.Component<ServerRouterProps, {}> { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.