I'm beginnner and I create my first app in React JS this is my code now:
function formatName(user) {
return user.firstName + ' ' + user.lastName;
}
function formatCountry(user) {
return user.country;
}
//this is my objet base of the user
const user = {
firstName: 'Simon',
lastName: 'willians',
country:'USA'};
const element = <h1>Hello, {formatName(user)}!</h1>;
const element2 = <h1>Country,{formatCountry(user)}!</h1>;
ReactDOM.render(element, document.getElementById('root'));
ReactDOM.render(element, document.getElementById('root'));
<div id="root"></div>
I create this app follow this tutorial of Facebook React JS
Okay I created a object with name user I return this object from formatName and formatCountry and the element of the object whatever exist in the object .
I try call country too in this sentence:
const element2 = <h1>Country,{formatCountry(user)}!</h1>;
any expert in React JS could tell me where is my error or where I mistakes?
elementandelement2components.