1//// [file.tsx] 2import React = require('react'); 3 4interface IUser { 5 Name: string; 6} 7 8interface IFetchUserProps { 9 children: (user: IUser) => JSX.Element; 10} 11 12class FetchUser extends React.Component<IFetchUserProps, any> { 13 render() { 14 return this.state 15 ? this.props.children(this.state.result) 16 : null; 17 } 18} 19 20// Error 21function UserName() { 22 return ( 23 <FetchUser> 24 { user => ( 25 <h1>{ user.NAme }</h1> 26 ) } 27 </FetchUser> 28 ); 29} 30 31function UserName1() { 32 return ( 33 <FetchUser> 34 35 36 37 { user => ( 38 <h1>{ user.Name }</h1> 39 ) } 40 { user => ( 41 <h1>{ user.Name }</h1> 42 ) } 43 </FetchUser> 44 ); 45} 46 47//// [file.jsx] 48"use strict"; 49var __extends = (this && this.__extends) || (function () { 50 var extendStatics = function (d, b) { 51 extendStatics = Object.setPrototypeOf || 52 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 53 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; 54 return extendStatics(d, b); 55 }; 56 return function (d, b) { 57 if (typeof b !== "function" && b !== null) 58 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); 59 extendStatics(d, b); 60 function __() { this.constructor = d; } 61 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 62 }; 63})(); 64exports.__esModule = true; 65var React = require("react"); 66var FetchUser = /** @class */ (function (_super) { 67 __extends(FetchUser, _super); 68 function FetchUser() { 69 return _super !== null && _super.apply(this, arguments) || this; 70 } 71 FetchUser.prototype.render = function () { 72 return this.state 73 ? this.props.children(this.state.result) 74 : null; 75 }; 76 return FetchUser; 77}(React.Component)); 78// Error 79function UserName() { 80 return (<FetchUser> 81 {function (user) { return (<h1>{user.NAme}</h1>); }} 82 </FetchUser>); 83} 84function UserName1() { 85 return (<FetchUser> 86 87 88 89 {function (user) { return (<h1>{user.Name}</h1>); }} 90 {function (user) { return (<h1>{user.Name}</h1>); }} 91 </FetchUser>); 92} 93