Chapter 4 - Add react and JSX compiler (babel)
This commit is contained in:
18
index.html
18
index.html
@@ -2,21 +2,13 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script type="text/javascript">
|
<script src="https://unpkg.com/react@17/umd/react.development.js"></script>
|
||||||
|
<script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>
|
||||||
|
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
||||||
|
<script type="text/jsx">
|
||||||
const app = document.getElementById('app');
|
const app = document.getElementById('app');
|
||||||
|
|
||||||
// Create a new H1 element
|
ReactDOM.render(<h1>Develop. Preview. Ship.</h1>, app);
|
||||||
const header = document.createElement('h1');
|
|
||||||
|
|
||||||
// Create a new text node for the H1 element
|
|
||||||
const text = 'Develop. Preview. Ship.';
|
|
||||||
const headerContent = document.createTextNode(text);
|
|
||||||
|
|
||||||
// Append the text to the H1 element
|
|
||||||
header.appendChild(headerContent);
|
|
||||||
|
|
||||||
// Place the H1 element inside the div
|
|
||||||
app.appendChild(header);
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user