Reputation: 749
I have this arrow function in react:
const Welcome = ({subject, description}) => (
<div>
<Person title={`Welcome ${subject}`}></Person>
<Profile description={description}></Profile>
</div>
)
and I would like to convert to an es5 function but I am not able to get it to work:
var Welcome = function(subject,description) {
return(
<Person title="Welcome ".concat(subject)/>
<Profile description=(description)/>
);
};
How should I go about it? Thanks
Upvotes: 2
Views: 150
Reputation: 29282
You need to do following steps:
{ }
around 'Welcome'.concat(subject)
and description
.var Welcome = function({subject, description}) {
return(
<div>
<Person title={ 'Welcome'.concat(subject) }/>
<Profile description={description}/>
</div>
);
};
Upvotes: 4
Reputation: 778
You forgot the destructuring in the params and also fogot to wrap the the html content under one parent tag
var Welcome = function({subject,description}) {
return(
<div>
<Person title="Welcome ".concat(subject)/>
<Profile description=(description)/>
</div>
);
};
Upvotes: 0
Reputation: 1143
var Welcome = function(subject,description) {
return(
<div>
<Person title={"Welcome ".concat(subject)}/>
<Profile description={description}/>
</div>
);
};
try this bro
Upvotes: 0