I am trying to pass some data from a child component to a parent component by following these docs: https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.events_create_dispatch

However, for me, the data returned is always NaN. However, the parent component can see that an event is happening.

here are my code blocks!

Parent Component:

    @track loaded = false;

    initalData = [];

    @wire(getConnections) proccessData({ error, data }) {
        if (data) {
            this.initalData = data;
            this.loaded = true;
        } else {

    onSelected(event) {
        console.log('Event from Child', + event.detail);
    <div class="slds-box slds-theme_default">
        <div class="slds-is-relative">
            <div if:false={loaded} class="">
                <lightning-spinner alternative-text="Loading" size="large" variant="brand"></lightning-spinner>

            <div if:true={loaded}>
            <c-frontend_visualpicker connection-data={initalData} onselected={onSelected}></c-frontend_visualpicker>

Child Component JS:


        // event.preventDefault()
        const eventdata = event.target.dataset.id;
        const selectedEvent = new CustomEvent('selected', { detail: eventdata});
       console.log('data: ' + eventdata);        


Also here is how it looks like in dev console in chrome, ideally the event data should appear in both console.logs: dev console example

2 Answers 2


The problem is that you have a '+' before your event.detail in the log call right after a comma: console.log('Event from Child', + event.detail);

You should instead write:

console.log('Event from Child', event.detail);


console.log('Event from Child ' + event.detail);

  • Oh man thank you! Such a simple and dumb mistake on my end.
    – scarecrow
    Jan 24, 2022 at 17:13

Please try to put on the onSelected method this:

    onSelected(event) {
        console.log('Event from Child', + event);

to see if you have receiving something

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .