React takes what we have written, and passes it to a function called React.createElement(). This function turns our code into DOM elements with all of their appropriate handlers, styles and attributes laid out.
What we get with react is this idea of composability because all we have to do is think about React elements as smaller pieces of UI, and build out those small pieces of UI in these code blocks we call components.
Everything you do in react will done through this createElement() method however, as you’ll see in the coming material,this has now been abstracted away from us and we now have the ability to use this new technology called JSX to write out our react elements.
index.html file with the following scaffolding<!DOCTYPE html>
<html lang="en">
<head>
<title>Hello World React</title>
</head>
<body>
<div id="target"></div>
</body>
<script>
// Our app goes in between these script tags
</script>
</html>
<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>
// Our app goes in between these script tags
</script>
React.createElement() and make an h1 element with a class="heading" and some child text Hello world <script>
const myElement = React.createElement('h1', {className:'heading'}, 'Hello World');
</script>
ReactDOM library to target where our application will live, and inject our newly created myElement element using the .render method<script>
const myElement = React.createElement('h1', {className:'heading'}, 'Hello World');
ReactDOM.render(myElement, document.getElementById('target'));
</script>
Notice we are passing our myElement as the first argument to render and we’re selecting our <div id="target"></div>. For every single react application you’ll ONLY DO THIS ONE TIME for a single application. Everything else well be built out as a child of this.
Steps to complete this assignment
index.html file<div id="target"></div> as the container for your application to live.type = “text/javascript” so that you can write your react application inlineconst myElement = React.createElement()ReactDOM.render