Ami*_*mir 14 typescript reactjs
我不确定我应该在反应类组件中标记我的方法.我在这些方法上收到此错误: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>
);
}
}
Run Code Online (Sandbox Code Playgroud)
我不能把私有render()等因为破坏组件.
Dav*_*ret 24
这是tslint 成员访问规则.
在tslint.json中,更改:
"member-access": true
Run Code Online (Sandbox Code Playgroud)
至:
"member-access": [true, "no-public"] // Or false. Read the rule and see what you want.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8607 次 |
| 最近记录: |