【发布时间】:2017-10-11 06:10:16
【问题描述】:
type ButtonProps = {
children: React.Node,
href: string,
onClick: Function,
};
const Button = (props: ButtonProps) => (
<a href={props.href} onClick={props.onClick}>
<button type="submit">
<span>{props.children}</span>
</button>
</a>
);
function hoc<Props: {}>(
Component: React.ComponentType<Props>,
): React.ComponentType<Props> {
return function WrapperComponent(props: Props) {
return <Component {...props} />;
};
}
export default hoc(Button);
我想要实现的是一个通用的高阶组件,它可以包装任何类组件以及无状态功能组件。上面的简化实现几乎取自https://flow.org/en/docs/react/hoc/。
这给了我以下错误,我不完全理解,因为我的印象是我正在遵循文档中提供的示例:
type parameter `Props` of function call. Missing annotation
【问题讨论】:
标签: javascript reactjs flowtype