Learn the fundamentals of React, including simple and class components, state, props, and submitting form data.
Last active
December 28, 2018 14:11
-
-
Save h4091/fc2b81b90983c293f761e9436f644939 to your computer and use it in GitHub Desktop.
Test2
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
<div id="root"> | |
<!-- This div's content will be managed by React. --> | |
</div> |
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; | |
} | |
function getGreeting(user) { | |
if (user) { | |
return <h1>Hello,{formatName(user)}!</h1>; | |
} | |
return <h1>Hello, Stranger.</h1>; | |
} | |
const user = { | |
firstName : 'Harper', | |
lastName : 'Perez' | |
}; | |
const element = ( | |
<div> | |
{getGreeting(user)} | |
{getGreeting()} | |
</div> | |
); | |
ReactDOM.render( | |
element, | |
document.getElementById('root') | |
); |
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
<script src="https://unpkg.com/react/umd/react.development.js"></script> | |
<script src="https://unpkg.com/react-dom/umd/react-dom.development.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment