1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import type {ComponentClass, ComponentType, FunctionComponent, ReactNode} from 'react';
- import type {InjectedRouter, PlainRoute, WithRouterProps} from 'react-router';
- import type {Location} from 'history';
- declare module 'react-router' {
- // React 18 removed children from ComponentType, this adds them back
- interface RouterProps {
- children?: ReactNode;
- }
- // React 18 removed children from ComponentType, this adds them back
- interface RouteProps {
- children?: ReactNode;
- }
- interface InjectedRouter<P = Record<string, string>, Q = any> {
- location: Location<Q>;
- params: P;
- routes: PlainRoute[];
- }
- interface WithRouterProps<P = Record<string, string>, Q = any> {
- location: Location<Q>;
- params: P;
- router: InjectedRouter<P, Q>;
- routes: PlainRoute[];
- }
- interface RouteContextInterface {
- location: Location<Q>;
- params: P;
- router: InjectedRouter<P, Q>;
- routes: PlainRoute[];
- }
- type ComponentConstructor<P> =
- | ComponentClass<P>
- | FunctionComponent<P>
- | ComponentType<P>;
- declare function withRouter<P extends WithRouterProps>(
- component: ComponentConstructor<P>,
- options?: Options
- ): ComponentClass<Omit<P, keyof WithRouterProps>>;
- declare function withRouter<P extends WithRouterProps, S>(
- component: ComponentConstructor<P> & S,
- options?: Options
- ): ComponentClass<Omit<P, keyof WithRouterProps>> & S;
- }
|