mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-18 12:08:59 +08:00
Merge pull request #17611 from tkrotoff/react-router-component
Refactoring: use React.ComponentType
This commit is contained in:
2
types/react-router-config/index.d.ts
vendored
2
types/react-router-config/index.d.ts
vendored
@@ -14,7 +14,7 @@ export interface RouteConfigComponentProps<T> extends RouteComponentProps<T> {
|
||||
|
||||
export interface RouteConfig {
|
||||
location?: Location;
|
||||
component?: React.SFC<RouteConfigComponentProps<any> | void> | React.ComponentClass<RouteConfigComponentProps<any> | void>;
|
||||
component?: React.ComponentType<RouteConfigComponentProps<any> | {}>;
|
||||
path?: string;
|
||||
exact?: boolean;
|
||||
strict?: boolean;
|
||||
|
||||
4
types/react-router/index.d.ts
vendored
4
types/react-router/index.d.ts
vendored
@@ -64,7 +64,7 @@ export interface RouteComponentProps<P> {
|
||||
|
||||
export interface RouteProps {
|
||||
location?: H.Location;
|
||||
component?: React.SFC<RouteComponentProps<any> | undefined> | React.ComponentClass<RouteComponentProps<any> | undefined>;
|
||||
component?: React.ComponentType<RouteComponentProps<any> | {}>;
|
||||
render?: ((props: RouteComponentProps<any>) => React.ReactNode);
|
||||
children?: ((props: RouteComponentProps<any>) => React.ReactNode) | React.ReactNode;
|
||||
path?: string;
|
||||
@@ -99,4 +99,4 @@ export interface match<P> {
|
||||
}
|
||||
|
||||
export function matchPath<P>(pathname: string, props: RouteProps): match<P> | null;
|
||||
export function withRouter<P>(component: React.SFC<RouteComponentProps<any> & P> | React.ComponentClass<RouteComponentProps<any> & P>): React.ComponentClass<P>;
|
||||
export function withRouter<P>(component: React.ComponentType<RouteComponentProps<any> & P>): React.ComponentClass<P>;
|
||||
|
||||
@@ -22,7 +22,7 @@ const PreventingTransitionsExample = () => (
|
||||
</Router>
|
||||
);
|
||||
|
||||
class Form extends React.Component<undefined, {isBlocking: boolean}> {
|
||||
class Form extends React.Component<{}, {isBlocking: boolean}> {
|
||||
state = {
|
||||
isBlocking: false
|
||||
};
|
||||
|
||||
2
types/react/index.d.ts
vendored
2
types/react/index.d.ts
vendored
@@ -36,7 +36,7 @@ declare namespace React {
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type ReactType = string | ComponentType<any>;
|
||||
type ComponentType<P> = ComponentClass<P> | StatelessComponent<P>;
|
||||
type ComponentType<P = {}> = ComponentClass<P> | StatelessComponent<P>;
|
||||
|
||||
type Key = string | number;
|
||||
type Ref<T> = string | ((instance: T | null) => any);
|
||||
|
||||
6
types/rrc/index.d.ts
vendored
6
types/rrc/index.d.ts
vendored
@@ -22,10 +22,10 @@ export interface WithScrollOptions {
|
||||
alignToTop?: boolean;
|
||||
}
|
||||
|
||||
export type ComponentConstructor<Props> = React.ComponentClass<Props> | React.SFC<Props>;
|
||||
export type ComponentConstructor<Props> = React.ComponentType<Props>;
|
||||
|
||||
export function withScroll(component: ComponentConstructor<RouteComponentProps<any> | undefined>, options?: WithScrollOptions)
|
||||
: ComponentConstructor<RouteComponentProps<any> | undefined>;
|
||||
export function withScroll(component: ComponentConstructor<RouteComponentProps<any> | {}>, options?: WithScrollOptions)
|
||||
: ComponentConstructor<RouteComponentProps<any> | {}>;
|
||||
|
||||
export type RouteConfiguration = RouteProps & { inject?: { [key: string]: any } };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user