【发布时间】:2021-03-22 15:49:04
【问题描述】:
我正在开发一个带有 lit-HTML 和 haunted 的 Web 组件库。 我需要创建一个 HOC,因为我想在将道具传递给我的组件之前更新它们。 我尝试了一些东西,效果很好。
const hoc = (WrappedComponent) => (props) => {
// here I update my props with a custom hooks
const newProps = useProps(props);
return WrappedComponent(newProps);
};
但是现在,“this”在我的组件中是未定义的。 我尝试绑定“this”,但没有任何效果。 “this”仍未定义
如果有人已经尝试创建高阶组件?你能分享我一些例子吗,请
【问题讨论】:
-
WrappedComponent是函数式组件还是类组件?
标签: javascript web-component lit-html high-order-component