React在组件中直接使用dispatch好呢 还是用action函数来处理优雅

2025-05-18 02:08:42
推荐回答(1个)
回答(1):

componentWillUnmount() {
this.timer && clearTimeout(this.timer);
this.props.dispatch({type : 'USER_ALL_CLEAR'});
}
componentWillUnmount() {
this.timer && clearTimeout(this.timer);
this.props.userAction.clearAll();