Created
May 23, 2020 08:40
-
-
Save Phonbopit/b9d90782484e02d2e830d8b03cbe4d9f to your computer and use it in GitHub Desktop.
React 101 - EP. 1
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>React 101 By Devahoy</title> | |
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script> | |
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script> | |
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> | |
</head> | |
<body> | |
<div id="myApp"></div> | |
<script type="text/babel"> | |
// 1. Class Component | |
class MyCard extends React.Component { | |
render() { | |
return ( | |
<div className="card"> | |
<div className="card-title">Title</div> | |
<div className="card-content">Content</div> | |
<Ahoy message="This is react 101 tutorial on Youtube" /> | |
<Ahoy2 title="This is my custom title" /> | |
</div> | |
) | |
} | |
} | |
// 2. Function Component | |
const Ahoy = function (props) { | |
const message = props.message; | |
return ( | |
<React.Fragment> | |
<h1>Ahoy!!!!!!</h1> | |
<p>{message}</p> | |
</React.Fragment> | |
) | |
} | |
// 3. Arrow function component | |
const Ahoy2 = ({ title = 'This is default title' }) => <h1>{title}</h1> | |
const myApp = document.getElementById('myApp'); | |
ReactDOM.render(<MyCard />, myApp) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment