如何解决在装饰器类中无法访问静态属性
我有一个添加了类装饰器的类。由于装饰器,静态方法和属性不可访问。在尝试访问该属性时,在该属性上获得 undefined
。
@BackInTimeWrapper()
class BarChart2 extends React.Component {
static staticValues = {
events: ["seriesClick"],};
render() {
return (<div>Sample</div>)
}
}
class NewChart extends React.Component<any> {
render() {
console.log("Static Props",BarChart2.staticValues); // getting undefined here
return (<BarChart2 {...this.props as any} />)
}
}
静态方法也是如此。是否应该在使用装饰器的类中不使用静态变量?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。