我有一个组件,它有一个状态对象,例如;
this.state = {
actionResponse: null,
};
我检查了 actionResponse 的值
componentDidUpdate(prevProps){
if (this.props.detailState.actionResponse !== prevProps.detailState.actionResponse) {
this.showToast(this.props.detailState.actionResponse,'bottom','OK', 'danger');
}
}
我第一次使用该组件时,它会调用 showToast 方法并返回。第二次它不调用 showToast 因为 actionResponse 是相同的。我应该在 goBack() 上重置 actionResponse 的值吗?或者有没有其他方法可以处理?