mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 13:00:19 +00:00
add component? to @reach/router router component (#29610)
* add component? to @reach/router router component * increase version * fix issues
This commit is contained in:
Vendored
+12
-11
@@ -1,4 +1,4 @@
|
||||
// Type definitions for @reach/router 1.0
|
||||
// Type definitions for @reach/router 1.2
|
||||
// Project: https://github.com/reach/router
|
||||
// Definitions by: Kingdaro <https://github.com/kingdaro>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -18,12 +18,13 @@ export interface History {
|
||||
export type HistoryListener = () => void;
|
||||
export type HistoryUnsubscribe = () => void;
|
||||
|
||||
export class Router extends React.Component<RouterProps> {}
|
||||
export class Router extends React.Component<RouterProps> { }
|
||||
|
||||
export interface RouterProps {
|
||||
basepath?: string;
|
||||
primary?: boolean;
|
||||
location?: WindowLocation;
|
||||
component?: React.ComponentType | string;
|
||||
}
|
||||
|
||||
export type RouteComponentProps<TParams = {}> = Partial<TParams> & {
|
||||
@@ -38,11 +39,11 @@ export type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
|
||||
|
||||
export type AnchorProps = Omit<
|
||||
React.DetailedHTMLProps<
|
||||
React.AnchorHTMLAttributes<HTMLAnchorElement>,
|
||||
HTMLAnchorElement
|
||||
React.AnchorHTMLAttributes<HTMLAnchorElement>,
|
||||
HTMLAnchorElement
|
||||
>,
|
||||
"href" // remove href, as it's ignored by the router
|
||||
>;
|
||||
>;
|
||||
|
||||
export interface LinkProps<TState> extends AnchorProps {
|
||||
to?: string;
|
||||
@@ -58,7 +59,7 @@ export interface LinkGetProps {
|
||||
location: WindowLocation;
|
||||
}
|
||||
|
||||
export class Link<TState> extends React.Component<LinkProps<TState>> {}
|
||||
export class Link<TState> extends React.Component<LinkProps<TState>> { }
|
||||
|
||||
export interface RedirectProps<TState> {
|
||||
from?: string;
|
||||
@@ -68,7 +69,7 @@ export interface RedirectProps<TState> {
|
||||
replace?: boolean;
|
||||
}
|
||||
|
||||
export class Redirect<TState> extends React.Component<RedirectProps<TState>> {}
|
||||
export class Redirect<TState> extends React.Component<RedirectProps<TState>> { }
|
||||
|
||||
export interface MatchProps<TParams> {
|
||||
path: string;
|
||||
@@ -85,7 +86,7 @@ export interface MatchRenderProps<TParams> {
|
||||
navigate: NavigateFn;
|
||||
}
|
||||
|
||||
export class Match<TParams> extends React.Component<MatchProps<TParams>> {}
|
||||
export class Match<TParams> extends React.Component<MatchProps<TParams>> { }
|
||||
|
||||
export type NavigateFn = (to: string, options?: NavigateOptions<{}>) => void;
|
||||
|
||||
@@ -98,7 +99,7 @@ export interface LocationProps {
|
||||
children: LocationProviderRenderFn;
|
||||
}
|
||||
|
||||
export class Location extends React.Component<LocationProps> {}
|
||||
export class Location extends React.Component<LocationProps> { }
|
||||
|
||||
export interface LocationProviderProps {
|
||||
history: History;
|
||||
@@ -114,13 +115,13 @@ export interface LocationContext {
|
||||
navigate: NavigateFn;
|
||||
}
|
||||
|
||||
export class LocationProvider extends React.Component<LocationProviderProps> {}
|
||||
export class LocationProvider extends React.Component<LocationProviderProps> { }
|
||||
|
||||
export interface ServerLocationProps {
|
||||
url: string;
|
||||
}
|
||||
|
||||
export class ServerLocation extends React.Component<ServerLocationProps> {}
|
||||
export class ServerLocation extends React.Component<ServerLocationProps> { }
|
||||
|
||||
export const navigate: NavigateFn;
|
||||
|
||||
|
||||
@@ -22,6 +22,12 @@ const NotFound = (props: RouteComponentProps) => <div>Route not found</div>;
|
||||
|
||||
render(
|
||||
<Router>
|
||||
<Router component="div">
|
||||
<Home path="/" />
|
||||
</Router>
|
||||
<Router component={Home}>
|
||||
<Home path="/" />
|
||||
</Router>
|
||||
<Home path="/" />
|
||||
<Dash path="/default/:id" />
|
||||
<NotFound default />
|
||||
|
||||
Reference in New Issue
Block a user