You need to sign in to do that
Don't have an account?
Ryan Avent 14
unable to read properties from customEvent
I have a custom event that is dispatched from my clild LWC
Event dispached from child:
spinner(boolean){ console.log('set spinner - ' + boolean); const spinner = new CustomEvent('spinnernotification', { display: boolean }); this.dispatchEvent(spinner); }
The event is being retrieved by the parent LWC but i am unable to read the display property, and am getting an undefined.
Console lines:
set spinner - false
called with display value undefined
Parent LWC:
displaySpinner(customEvent){ if(null != customEvent){ console.log('called with display value ' + customEvent.display); this.spinner = customEvent.display; }else{ console.log('customEvent display is null'); this.spinner = false; } }
if i stringify the customEvent in the parent all i see is the below:
value {"isTrusted":false,"composed":false}
Try this:
And access to the value using customEvent.detail.display in the parent