我不确定应该在我的反应类组件中标记什么方法。我在以下方法上遇到此错误: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> ); } }
我不能放私有的render()等,因为那会破坏组件。
这是tslint 成员访问规则。
在 tslint.json中 ,更改:
"member-access": true
至:
"member-access": [true, "no-public"] // Or false. Read the rule and see what you want.