What to do in this case - cannot read property split of undefined?
I have the following LWC, when I try to add on my lightning record page I get some error like, cannot read property of split.
js:
import { LightningElement, api, track } from 'lwc';
export default class CustomRecordDetail extends LightningElement {
@track fieldArray;
connectedCallback()
{
if(this.fields !== null && typeof this.fields !== undefined && this.fields !== '')
{
this.fieldArray = this.fields.split(",");
}
}
}
html :
record-id={recordId}
fields={fieldArray}>
xml:
<?xml version="1.0" encoding="UTF-8"?>50.0
true
lightning__RecordPage
In case of - cannot read property split of undefined:
import { LightningElement, api, track } from 'lwc'; export default class CustomRecordDetail extends LightningElement { @track fieldArray; @track fields="How are you doing today?"; connectedCallback() { if(!this.fields) { this.fieldArray = this.fields.split(" "); } } }