For example:
function Avatar(props) {
return (
<img className="Avatar"
src={props.user.avatarUrl}
alt={props.user.name}
/>
);
}
function Comment(props) {
return (
<div className="Comment">
<div className="UserInfo">
<Avatar user={props.author} />
<div className="UserInfo-name">
{props.author.name}
Why can't I use {Avatar(props.author)} or {Avatar() user={props.author}}? I know that I can use functions inside curly bracets, how it works?
Well, if the child receive props and return
jsxit will be considered as React Element or React Node, in this case you can use it like<Avatar user={props.author} />.If you want to use functions inside
Commentsimply like this:CommentComponent