0

我无法将 HOC 的反应特性与功能组件一起使用。在下面的代码中导出默认 HOC({component: SampleComponent}) 不起作用

const SampleComponent: FC = () => {
  return (<div>Hello World</div>);
};

export default HOC({ component: SampleComponent });

HOC 很简单

const HOC = ({ component: Component }) => {
  return (<Component/>);
}
4

1 回答 1

0

HOC应该是

const HOC = ({ component: Component }) => {
  return (props: {}) => (<Component/>);
}
于 2020-04-12T06:16:48.400 回答