Writing a React higher-order component with TypeScript

Writing a React higher-order component with TypeScript,第1张

Writing a React higher-order component with TypeScript

我找到了一种使其工作的方法:通过使用

hoc
提供的
type
参数调用
,如下所示:

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

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



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5642378.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存