简体   繁体   中英

How to fix “Unexpected block statement surrounding arrow body; move the returned value immediately after the =>” ESLint error?

I'm getting this error

Unexpected block statement surrounding arrow body; move the returned value immediately after the =>"

for the code below:

let guestBeingEdited = SJ.Event.ListItem.previouslyAddedGuests.filter(
    guest => {
        return guest.id === SJ.Event.ListItem.selectPrevGuest;
    },
);

I tried different suggestions from here but couldn't get it fixed. Any suggestions?

The block body and return statement are unnecessary. It's asking you to change your code to this:

let guestBeingEdited = SJ.Event.ListItem.previouslyAddedGuests.filter(
    guest => guest.id === SJ.Event.ListItem.selectPrevGuest
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM