Created
August 18, 2017 10:54
-
-
Save alainlompo/04afe047651ddab9b3c93b04a25cca99 to your computer and use it in GitHub Desktop.
Simple jsx sample snippets to familiarize the beginner with its key concepts and syntax (Episode 1 of probably many...)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function formatName(user) { | |
return user.firstName + ' ' + user.lastName; | |
} | |
const user = { | |
firstName:'Harper', | |
lastName:'Perez' | |
}; | |
const element = ( | |
<h1> | |
hello, {formatName(user)}! | |
</h1> | |
); | |
ReactDOM.render(element, | |
document.getElementById('root') | |
); | |
function getGreeting(user) { | |
if (user) { | |
return <h1>Hello, {formatName(user)}!</h1> | |
} | |
return <h1>Hello, Stranger </h1>; | |
} | |
const element2 = <div tableIndex="0"></div> | |
const element3 = <img src={user.avatarUrl} /> | |
const element4 = ( | |
<div> | |
<h1>Hello!</h1> | |
<h2> Good to see you here.</h2> | |
</div> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment