如何在Typescript tsx中遍历React组件的子级?
以下是有效的jsx:
public render() {
return (
<div>
{React.Children.map(this.props.children, x => x.props.foo)}
</div>
);
}
然而,在Typescript中,x的类型是React.ReactElement<any>
,所以我无法访问props .有什么样的演员我需要做吗?