Open MayHyeyeonKim opened 1 month ago
When we write an arrow function in JS, sometimes we need to use return to tell the function what to give back, and other times, we dont.
return
if we use { } (curly braces) in our arrow function, we must use return.
hospitals.map(hospital => { return ( <Marker key={hospital.id} latitude={hospital.latitude} longitude={hospital.longitude} /> ); });
if we use ()(parentheses) without { }, we dont need to use return. This is called implicit return, and it works when you have a simple, one-line expression. The function automatically returns the value.
hospitals.map(hospital => ( <Marker key={hospital.id} latitude={hospital.latitude} longitude={hospital.longitude} /> ));
When we write an arrow function in JS, sometimes we need to use
return
to tell the function what to give back, and other times, we dont.if we use { } (curly braces) in our arrow function, we must use
return
.if we use ()(parentheses) without { }, we dont need to use
return
. This is called implicit return, and it works when you have a simple, one-line expression. The function automatically returns the value.