1 | import { Component, ComponentClass, ComponentLifecycle, ReactNode } from "react";
|
2 |
|
3 | declare namespace createReactClass {
|
4 | interface Mixin<P, S> extends ComponentLifecycle<P, S> {
|
5 | mixins?: Array<Mixin<P, S>> | undefined;
|
6 | statics?: {
|
7 | [key: string]: any;
|
8 | } | undefined;
|
9 |
|
10 | displayName?: string | undefined;
|
11 | |
12 |
|
13 |
|
14 |
|
15 | propTypes?: any;
|
16 |
|
17 | getDefaultProps?(): P;
|
18 | getInitialState?(): S;
|
19 | }
|
20 |
|
21 | interface ComponentSpec<P, S> extends Mixin<P, S> {
|
22 | render(): ReactNode;
|
23 |
|
24 | [propertyName: string]: any;
|
25 | }
|
26 | interface ClassicComponent<P = {}, S = {}> extends Component<P, S> {
|
27 | replaceState(nextState: S, callback?: () => void): void;
|
28 | isMounted(): boolean;
|
29 | getInitialState?(): S;
|
30 | }
|
31 |
|
32 | interface ClassicComponentClass<P = {}> extends Omit<ComponentClass<P>, "new"> {
|
33 | new(props: P, context?: any): ClassicComponent<P, any>;
|
34 | getDefaultProps?(): P;
|
35 | }
|
36 | }
|
37 | declare function createReactClass<P, S = {}>(
|
38 | spec: createReactClass.ComponentSpec<P, S>,
|
39 | ): createReactClass.ClassicComponentClass<P>;
|
40 |
|
41 | export as namespace createReactClass;
|
42 | export = createReactClass;
|