当我先单击添加患者时,它可以正常工作,但是再次单击添加患者按钮,页面崩溃。我该怎么办?
render() {
const { patientsMasterData, addPatientForm, onGetTimelyFiling, PatientInfo,addRelatedClaim } = this.props;
return (
<ul className="add-list add-patient-menu">
<li>
<div className="add-list_key">
Referred By<span className="add-list_required"> *</span>
</div>
{/* <div className="add-list_value">
<Field
name="ReferredBy"
component="select"
onChange={this.onChange}>
<option value="0">Select</option>
{patientsMasterData.ReferredBy && patientsMasterData.ReferredBy.map(referredObj =>
<option key={referredObj.RefID} value={referredObj.RefID}>{referredObj.RefName}</option>
)}
</Field> */}
<div className="add-list_value1">
<ReactAutocomplete
name="ReferredBy"
items = {patientsMasterData && patientsMasterData.ReferredBy && patientsMasterData.ReferredBy.map(referredObj =>(
{options:referredObj.RefName,
values:referredObj.RefID}
))
}
shouldItemRender={(item, value) => item.options.toLowerCase().indexOf(value.toLowerCase()) > -1}
getItemValue={(item) => item.options}
renderItem={(item, highlighted) =>
<div
key={item.values}
style={{ backgroundColor: highlighted ? '#3db4e5' : '#FFFFFF',cursor:'pointer', border:'1px solid lighten($grey-element,30%)',padding: '5px' }} >
{item.options}
</div>}
inputProps={{placeholder:'Select...'}}
menuStyle={this.props.menuStyle}
wrapperStyle={this.props.wrapperStyle}
value={this.state.value}
onChange={this.onValueChange}
onSelect={this.onValueChange}
/>
</div>
</li>
{addPatientForm && addPatientForm.values.ReferredBy && addPatientForm.values.ReferredBy!==0 &&
this.state.isSubref &&
<li>
<div className="add-list_key">
SubRef By<span className="add-list_required"> *
</span> </div>
<div className="add-list_value">
<Field name="SubRefID" component="select" >
<option value='0'>Select</option>
{patientsMasterData.SubRef && patientsMasterData.SubRef.map(referredObj =>
<option key={referredObj.SubRefID} value={referredObj.SubRefID}>{referredObj.Name}</option>
)}
</Field>
</div>
</li>
}
这是我的代码,为了避免崩溃,需要对我的代码进行哪些更改。在崩溃时,控制台显示错误,在addPatientForm && addPatientForm.values.ReferredBy && addPatientForm.values.ReferredBy!==0 && this.state.isSubref
中未定义此条件。
答案 0 :(得分:0)
还要添加addPatientForm.values
的检查项,让我知道它是否仍然崩溃。