我有this.props.isCsvHeadersColumnMismatch
的道具rootReducer.js
。我试图显示基于此props标志值的错误模式。
render = () => {
const csvColumnMismatchError =
this.props.csvColumnMismatch ?
Modal.error({
title: 'Error',
content: 'Sorry, CSV columns does not match with the recorded columns.',
}) : null;
return (
<Modal
visible={this.props.isCsvUploadModalVisible}
okText= {this.csvColumnMismatch}
title="CSV Upload"
onOk={() => this.props.handleCsvUpload(
appendOverrideFlag,
csvHeaders,
csvDescription,
)}
onCancel={this.resetModal}
zIndex={10}
>
{ csvColumnMismatchError }
// have other fields of modal here after.
</Modal>
);
}
使用此代码,组件多次渲染且每次弹出错误模态时都会出错。我知道这不是取得理想结果的正确方法。请帮忙!