我不确定应该在反应类组件中标记我的方法。我在这些方法上收到此错误:componentDidMount、componentDidUpdate、componentWillUpdate 和 render
这是我拥有的一个基本组件:
import * as React from 'react';
const { Component } = React;
export default class Loading extends Component<{}, {}> {
componentDidMount() {
console.log('....something....');
}
componentDidUpdate() {
console.log('....something....');
}
componentWillUpdate() {
console.log('....something....');
}
render() {
const style = {
background: '#f5f5f5',
height: '100%',
padding: '20px',
textAlign: 'center',
transition: 'all 0.5s linear',
width: '100%'
};
return (
<div id='app-loader' className='rounded' style={style}>
<div className='loader large block rounded'>Loading...</div>
</div>
);
}
}
我不能放置 private render() 等,因为这会破坏组件。
这是 tslint会员访问 https://palantir.github.io/tslint/rules/member-access/ rule.
In tslint.json, 改变:
"member-access": true
To:
"member-access": [true, "no-public"] // Or false. Read the rule and see what you want.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)