Reputation: 6186
The following code has this warning in console:
Unexpected block statement surrounding arrow body; move the returned value immediately after the =` arrow-body-style
blobToDataURL = blob => {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onerror = reject;
reader.onload = e => resolve(reader.result);
reader.readAsDataURL(blob);
});
};
What does it mean?
Upvotes: 1
Views: 229
Reputation: 17654
It wants you to use implicit return :
blobToDataURL = blob =>
new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onerror = reject;
reader.onload = e => resolve(reader.result);
reader.readAsDataURL(blob);
});
Upvotes: 2
Reputation: 943649
Arrow functions can take one of two forms:
() => return_value;
and
() => {
something;
something;
return return_value;
};
The warning you are getting is that you are using the second format even though you have only a single statement, which you are returning, so you can use the first form.
Upvotes: 4