React from absolute scratch (part-0)

Search for a command to run...

No comments yet. Be the first to comment.
In this series, I will write about everything you need to get started with ReactJs.I will try my best to simplify react on my own version.
The data landscape is rapidly evolving, and the amount of data being produced and distributed on a daily basis is downright staggering. According to the report by Statista, currently, there are approximately 120 zettabytes of data in existence (as of...

In today's day and age, data has become a crucial asset for organizations across all kinds of industries. Industry after industry—from retail to e-commerce to manufacturing to accounting to insurance to healthcare to finance—uses data to fuel innovat...

Introduction Data engineering is the process of designing, building, maintaining, and running systems and infrastructure for storing, processing, and analyzing large, complex datasets. It is a field that has recently become much more important becaus...
Introduction The topic of containerization has become increasingly important in the world of software/IT industries. Two of the most popular technologies for containerization are Docker and Containerd. While both of these technologies offer similar f...

Crafting documentation is difficult enough, but making it SEO friendly is a huge hurdle. In this article, I'll walk you through how to make documentation SEO friendly and what steps you need to take to get started from absolute scratch. This article ...

HELOOOO !! Everyone. In this blog, I will be teaching you React from absolute scratch. But before we start you need to have some very basic JavaScript, javascript DOM manipulation, HTML, and CSS knowledge .
Without any further ado ...Let's get started, shall we
But first,
const element = <h1>Hello, There!</h1>;
But first, Let's create a User Interface using Vanilla JavaScript and Document Object Model. Create a new empty project directory and add two file (index.html and app.js)
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vannila Javascript</title>
</head>
<body>
<div id="root"></div>
<script type="text/javascript" src="./app.js></script>
</body>
</html>
app.js
const rootElement = document.querySelector("#root")
const element = document.createElement("div")
element.textContent = "Hello There!!"
element.className = "container"
rootElement.appendChild(element)
index.html

app.js


Visit Here UNPKG
<script src="https://unpkg.com/react@16.12.0/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16.12.0/umd/react-dom.development.js"></script>

Now, inside your app.js remove all except rootElement.
let's use ReactDOM.render to render our element to our rootElement
In the previous javascript way, we attached properties of textContent to our element.
But, In react we specify our properties on the creation as a JavaScript Object and adding children and className inside it.
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Let's Do in React way</title>
</head>
<body>
<div id="root"></div>
<script type="text/javascript" src="./app.js></script>
</body>
</html>
app.js
const rootElement = document.querySelector("#root")
const element = React.createElement("div",{
children: "Hello from the react side",
className: "container",
})
ReactDOM.render(element,rootElement)
You can write the above app.js code by removing the children and adding it as an React.createElement third argument by simply providing the value for the children props.
app.js
const rootElement = document.querySelector("#root")
const element = React.createElement("div",{
// *children: "Hello from the react side",*
className: "container",
},"Hello from the react side")
ReactDOM.render(element,rootElement)

You can also add React.createElement and create another element inside children
app.js
const rootElement = document.querySelector("#root")
const element = React.createElement("div",{
children: React.createElement("span",null,"Hello form the react side")
className: "container",
})
ReactDOM.render(element,rootElement)
Cheerss!! Next part comming soon..
See you on the next part 🎉🎉