score:4

Accepted answer

yes, that is correct. when you have only one expression, and it's the expression you wish to return from the function, you may omit the curly brackets.

since <div><label>{props.placeholder}</label></div> is, in fact, a single expression (it gets transpiled to react.createelement(......) or something like that), and you wish to return it from renderinput, that is indeed how you use the no-brackets version of the arrow function.

if you had wished to use variables or do some other computation (conditions, for loops, etc), you wouldn't have been able to omit the brackets.


Related Query

More Query from same tag