fix rendering types for React 16

This commit is contained in:
Rasmus Eneman
2017-11-01 14:33:09 +01:00
parent 17f38a9945
commit 4657bbe7ac
2 changed files with 11 additions and 3 deletions
+3 -3
View File
@@ -286,7 +286,7 @@ declare namespace React {
// tslint:enable:unified-signatures
forceUpdate(callBack?: () => any): void;
render(): JSX.Element | JSX.Element[] | ReactPortal | string | number | null | false;
render(): ReactNode;
// React.Props<T> is now deprecated, which means that the `children`
// property is not available on `P` by default, even though you can
@@ -421,7 +421,7 @@ declare namespace React {
}
interface ComponentSpec<P, S> extends Mixin<P, S> {
render(): ReactElement<any> | Array<ReactElement<any>> | string | number | null;
render(): ReactNode;
[propertyName: string]: any;
}
@@ -3519,7 +3519,7 @@ declare global {
// tslint:disable:no-empty-interface
interface Element extends React.ReactElement<any> { }
interface ElementClass extends React.Component<any> {
render(): Element | Element[] | React.ReactPortal | string | number | null | false;
render(): React.ReactNode;
}
interface ElementAttributesProperty { props: {}; }
interface ElementChildrenAttribute { children: {}; }
+8
View File
@@ -698,3 +698,11 @@ declare var x: React.DOMElement<{
transition: string;
};
}, Element>;
// React 16 should be able to render its children directly
class RenderChildren extends React.Component {
render() {
const { children } = this.props;
return children !== undefined ? children : null;
}
}