I wrote this code a while ago and I came back to try and clean it by removing the map array and handlers out of the render operation but I keep getting syntax errors. How could I go about this? I’m getting the same error: Syntax error: Unexpected token, expected “,” but varying on how I try to separate it.
if (!sales) {
return (
<div>
<Spinner />
</div>
);
}
return (
<ul>
{sales.map((result) => {
const {
sale_id,
buyer,
seller,
listing_price,
listing_symbol,
created_at_time,
} = result;
function HandleBuyerClick() {
window.location = '/user/' + buyer;
}
function HandleSellerClick() {
window.location = '/user/' + seller;
}
if (buyer !== null) {
return (
<Card>
<li key={sale_id}>
<h3>
<Transaction>
<Button onClick={HandleSellerClick}>{seller}</Button>
</Transaction>{' '}
just sold item number
<Transaction>
<Button>{sale_id}</Button>
</Transaction>{' '}
to
<Transaction>
<Button onClick={HandleBuyerClick}>{buyer}</Button>
</Transaction>{' '}
for <Transaction>{formatNumber(listing_price)}</Transaction>{' '}
{listing_symbol} at {parseTimestampJM(created_at_time)}
</h3>
</li>
</Card>
);
}
})}
</ul>
);