您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Writing a React higher-order component with TypeScript

Writing a React higher-order component with TypeScript

我找到了一种使其工作的方法:通过使用hoc提供的type参数调用 ,如下所示:

import ChildComponent, { Props as ChildComponentProps } from './child';
const WrappedChildComponent = hoc<ChildComponentProps>()(ChildComponent);

但我不是很喜欢。它要求我导出孩子的道具 (我宁愿不这样做),我 有种感觉,我正在告诉TypeScript 它应该能够推断出的东西。

其他 2022/1/1 18:13:50 有462人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶