mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Discern new vs old style components through render
By overloading createElement() for the ClassicComponentClass and creating a separate ReactClassicElement type, we can keep track of which calls to render() should create a ClassicComponent versus a new style Component. Useful for keeping the old API, which makes migration easier.
This commit is contained in:
Vendored
+5
@@ -17,6 +17,9 @@ declare module React {
|
||||
ref: string;
|
||||
}
|
||||
|
||||
interface ReactClassicElement<P> extends ReactElement<P> {
|
||||
}
|
||||
|
||||
interface ReactHTMLElement extends ReactElement<HTMLAttributes> {}
|
||||
interface ReactSVGElement extends ReactElement<SVGAttributes> {}
|
||||
|
||||
@@ -112,8 +115,10 @@ declare module React {
|
||||
|
||||
interface TopLevelAPI {
|
||||
createClass<P, S, C>(spec: ComponentSpec<P, S, C>): ClassicComponentClass<P, S, C>;
|
||||
createElement<P>(type: ClassicComponentClass<P, any, any>, props: P, ...children: ReactNode[]): ReactClassicElement<P>;
|
||||
createElement<P>(type: ComponentClass<P, any, any> | string, props: P, ...children: ReactNode[]): ReactElement<P>;
|
||||
createFactory<P>(type: ComponentClass<P, any, any> | string): ComponentFactory<P>;
|
||||
render<P, S>(element: ReactClassicElement<P>, container: Element, callback?: () => any): ClassicComponent<P, S, any>;
|
||||
render<P, S>(element: ReactElement<P>, container: Element, callback?: () => any): Component<P, S, any>;
|
||||
unmountComponentAtNode(container: Element): boolean;
|
||||
renderToString(element: ReactElement<any>): string;
|
||||
|
||||
Reference in New Issue
Block a user