我正在使用与 typescript 和 react-redux 包进行react。
确实像文档中一样配置了组件 - https://react-redux.js.org/introduction/quick-start
console.log 正在处理连接功能,但组件生命周期不起作用。
容器.ts
import Toolbar from './Toolbar.Component';
export default connect<any, any, any>((store:any) => {
console.log('++++++++++++++++++++',store.toolbarComponent);
return store.toolbarComponent
}, {})(Toolbar)```
组件.ts
export default class ToolbarComponent extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {
activeProperty: '',
toolbarList: this.props.toolbarList
};
console.log('--- comp init ---', this.state);
this.dispatchData = this.dispatchData.bind(this);
}
UNSAFE_componentWillUpdate(){
console.log('-----', this.props.toolbarList, this.state.toolbarList)
}
componentWillUpdate(){
console.log('-----', this.props.toolbarList, this.state.toolbarList)
}
componentWillReceiveProps(){
console.log('-----', this.props.toolbarList, this.state.toolbarList)
}
componentDidUpdate(){
console.log('-----', this.props.toolbarList, this.state.toolbarList)
}
}