HTML inside JavaScript

Okay. Let's look at this function:

function Page() {
    return (
            <h1>Hello World</h1>
            <p>This is a paragraph</p>

Everything looks familiar, but the problem is what we are returning from it.

With React, we can use HTML (or sort of) inside JavaScript. It's possible because we usually use React with a transpiler, which converts this code block into JavaScript. This dialect of JavaScript is known as JSX.

šŸ¤” Okay. What is a transpiler?

Just don't overthink this; it's just like a compiler or a converter. You will use React with a framework like Create React App, Next.js or Gatsby. They will take care of transpiling & many other things for you.

Try to play with the HTML content inside the following function. Maybe add another paragraph. Or a list.

šŸ™ We need your help

We need your help to keep maintain & add new content to this course. Here's how you can support us: