SyntaxError: Unexpected newline after arrow
Quick summary
You wrote => on one line and the body on the next — the parser treats the arrow as having no body.
Why this happens
Line-wrapping an arrow function between => and the expression
Auto-formatter inserting a newline in an unfortunate place
Copying code that lost the single-line structure
Minimal example
const square = (x) =>
x * x; // may parse oddly or error in some contexts
console.log(square(5));const square = (x) => x * x; // same line — safe
console.log(square(5)); // 25A newline between => and the expression body can confuse the parser. Keeping the body on the same line (or using a block body) avoids the issue.
How to diagnose
Read the SyntaxError near the => token
Check whether a newline sits between => and the body
Wrap the body in braces if it must span multiple lines
How to fix
Keep the expression body on the same line as =>
Use a block body { return ...; } for multi-line arrow functions
Move the whole arrow function onto one line or use braces
How to prevent
Use a formatter that keeps arrow bodies consistent
Prefer block bodies for multi-line arrow functions