[React] Add SFC displayName and fix onlyChild type

- `StatelessComponent` is missing an optional `displayName` property
- `ReactChildren.only` always returns a `ReactElement`
- add tests for the above and `ReactTestUtils.renderIntoDocument`
This commit is contained in:
Vincent Siao
2015-12-09 12:07:28 -08:00
parent 7136728255
commit d76bfa3394
2 changed files with 10 additions and 4 deletions
+2 -1
View File
@@ -148,6 +148,7 @@ declare namespace __React {
propTypes?: ValidationMap<P>;
contextTypes?: ValidationMap<any>;
defaultProps?: P;
displayName?: string;
}
interface ComponentClass<P> {
@@ -2070,7 +2071,7 @@ declare namespace __React {
map<T>(children: ReactNode, fn: (child: ReactChild, index: number) => T): T[];
forEach(children: ReactNode, fn: (child: ReactChild, index: number) => any): void;
count(children: ReactNode): number;
only(children: ReactNode): ReactChild;
only(children: ReactNode): ReactElement<any>;
toArray(children: ReactNode): ReactChild[];
}