Merge pull request #17611 from tkrotoff/react-router-component

Refactoring: use React.ComponentType
This commit is contained in:
Ryan Cavanaugh
2017-07-10 09:41:41 -07:00
committed by GitHub
5 changed files with 8 additions and 8 deletions

View File

@@ -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;

View File

@@ -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>;

View File

@@ -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
};

View File

@@ -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);

View File

@@ -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 } };