Add React.Children tests and change callback param return types from void to any

This commit is contained in:
Vincent Siao
2014-12-08 15:41:47 -08:00
parent b4174b1ff1
commit 0fb398c774
2 changed files with 33 additions and 15 deletions
+15 -2
View File
@@ -119,12 +119,13 @@ myComponent.reset();
// Attributes
// --------------------------------------------------------------------------
var children = ["Hello world", [null], React.DOM.span(null)];
var divStyle = { // CSSProperties
flex: "1 1 main-size",
backgroundImage: "url('hello.png')"
};
var htmlAttr = {
children: ["Hello world", [null], React.DOM.span(null)],
children: children,
className: "test-attr",
style: divStyle,
onClick: (event: React.MouseEvent) => {
@@ -140,7 +141,7 @@ React.DOM.span(htmlAttr);
React.DOM.input(htmlAttr);
//
// PropTypes
// React.PropTypes
// --------------------------------------------------------------------------
var PropTypesSpecification: React.ComponentSpec<any, any> = {
@@ -180,6 +181,18 @@ var PropTypesSpecification: React.ComponentSpec<any, any> = {
}
};
//
// React.Children
// --------------------------------------------------------------------------
var childMap: { [key: string]: 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, {
test: null
}]);
//
// Example from http://facebook.github.io/react/
// --------------------------------------------------------------------------