...

/

First Component

First Component

We will create our first React Component and understand the usage of props in this lesson.

In our last lesson, we used ReactDom to insert a span into a div using the following code.

Press + to interact
ReactDOM.render(
<span>Hello, world!</span>,
document.getElementById('content')
)

Which is equivalent to

Press + to interact
const reactElement = <span>Hello, world!</span>;
ReactDOM.render(
reactElement,
document.getElementById('content')
)

You might be wondering why do we even need React for this. Programs like these can be created pretty quickly using Vanilla JS or JQuery. You are rightfully confused. Our Hello World example for React was simplistic. React's usefulness is readily understandable after we have learned about the Components in React.

What is a "Component"?

Component is the fundamental building block of React. The truth is that in React, creating components is the only thing that you do.

You may think of a ...

Access this course and 1400+ top-rated courses and projects.