mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 21:00:01 +08:00
Write typings for React.Children.toArray and React.Children.map
This commit is contained in:
@@ -331,11 +331,12 @@ var ContextTypesSpecification: React.ComponentSpec<any, any> = {
|
||||
// React.Children
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
var childMap: { [key: string]: number } =
|
||||
var mappedChildrenArray: number[] =
|
||||
React.Children.map<number>(children, (child) => { return 42; });
|
||||
React.Children.forEach(children, (child) => {});
|
||||
var nChildren: number = React.Children.count(children);
|
||||
var onlyChild = React.Children.only([null, [[["Hallo"], true]], false]);
|
||||
var childrenToArray: React.ReactChild[] = React.Children.toArray(children);
|
||||
|
||||
//
|
||||
// Example from http://facebook.github.io/react/
|
||||
|
||||
@@ -328,11 +328,12 @@ var ContextTypesSpecification: React.ComponentSpec<any, any> = {
|
||||
// React.Children
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
var childMap: { [key: string]: number } =
|
||||
var mappedChildrenArray: number[] =
|
||||
React.Children.map<number>(children, (child) => { return 42; });
|
||||
React.Children.forEach(children, (child) => {});
|
||||
var nChildren: number = React.Children.count(children);
|
||||
var onlyChild = React.Children.only([null, [[["Hallo"], true]], false]);
|
||||
var childrenToArray: React.ReactChild[] = React.Children.toArray(children);
|
||||
|
||||
//
|
||||
// Example from http://facebook.github.io/react/
|
||||
|
||||
@@ -329,11 +329,12 @@ var ContextTypesSpecification: React.ComponentSpec<any, any> = {
|
||||
// React.Children
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
var childMap: { [key: string]: number } =
|
||||
var mappedChildrenArray: number[] =
|
||||
React.Children.map<number>(children, (child) => { return 42; });
|
||||
React.Children.forEach(children, (child) => {});
|
||||
var nChildren: number = React.Children.count(children);
|
||||
var onlyChild = React.Children.only([null, [[["Hallo"], true]], false]);
|
||||
var childrenToArray: React.ReactChild[] = React.Children.toArray(children);
|
||||
|
||||
//
|
||||
// Example from http://facebook.github.io/react/
|
||||
|
||||
3
react/react.d.ts
vendored
3
react/react.d.ts
vendored
@@ -747,10 +747,11 @@ declare namespace __React {
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
interface ReactChildren {
|
||||
map<T>(children: ReactNode, fn: (child: ReactChild, index: number) => T): { [key:string]: T };
|
||||
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;
|
||||
toArray(children: ReactNode): ReactChild[];
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user