reactjs - ReactJS/Typescript 升级将 Child 的类型从 any 更改为 ReactNode
问题描述
最近尝试从 TypeScript 2.3(我知道)更新到 3.3 并遇到了 ReactJS 的问题,特别是 props.children 的类型。
this.props.children.map((s)=>{return <span>{s.prop1} - {s.prop2}</span>});
它曾经只是花花公子,但现在“孩子”是 ReactNode 类型而不是任何类型。这会导致编译器在“ReactNode”类型上不存在“map”时阻塞。
你们中的任何人都可以指出我克服这个障碍的方向吗?
解决方案
推荐阅读
- flurry - 如何动态创建广告系列?
- sql-server - iis express 上的 web 应用程序的配置问题
- .net - FileStream 缓冲区是否支持不自动刷新的随机写入?
- c# - 如何循环并仅提取标记之间的数据?
- kotlin - 测量 kotlin 协程性能
- java - 使用 Servlet -JSP 登录
- css - 在 wp_enqueue_style 中为不同的媒体设置多 css 文件
- sprite-kit - 为什么skscene的布局在所有设备中都不相同
- sql - 如何将一个表中的列及其值添加到 SQL 中的另一个表中?
- spring - 调用 init 方法失败;嵌套异常是 java.lang.IllegalStateException: 在 getOne 上没有指定查询