This series of articles is about React. In recent years, Single Page Applications (SPA) have been popular in web development associated with loosely coupled models. The major two SPA, Angular and React, are the most popular and almost used in anywhere. I used to be an Angular Developer. While I learned Angular, I started by myself without any training. That made my learning curve quite long, and even at a senior level, I am still not familiar with something I have not met. While for react, there is a chance in a training course. I got the concepts and skills in every course. I will share here the major points that could be helpful for any new React developer.
- React (1) - Installation and Environment Setup
- React (2) - JSX File --- this article
- React (3) --- Parameters
- React (4) --- Using Libraries
- React (5) --- CSS
- React (6) --- HTTP
- React (7) --- Routing
- React (8) ---
A. Introduction
React uses a syntax extension for JavaScript named JSX, which is a mix of JS and HTML (a subset of HTML). This article will discuss JSX.
- A. Introduction
- B. What is JSX
- C. React is Component-Based
- D. Function Component and Class Component
- E. VS Code Extensions
B. What is JSX?
Consider this variable declaration.
const element = <h1>Hello, world!</h1>;
- This funny tag syntax is neither a string nor HTML.
- It is called JSX, and it is a syntax extension to JavaScript.
- We recommend using it with React to describe what the UI should look like. JSX may remind you of a template language, but it comes with the full power of JavaScript.
- JSX produces React “elements”.
From wiki
JSX (JavaScript Syntax Extension, occasionally referred to as JavaScript XML) is a JavaScript extension that allows the creation of DOM trees using an XML-like syntax. Initially created by Meta for use with React, JSX has been adopted by multiple web frameworks.
C. React is Component-Based
index.html: Starting point.

Index.js: feed the root, containing App.js.

App.js: major component containing sub-components.

Sub-Component.

Render

React Entry Point: How index.html invoke index.js [ref]
In simple words: index.html is where all your UI is rendered by React and index.js is where all your JS codes exist. So browser, first get index.html and then renders the file. then JS index.js is responsible for all the logical rendering of UI, which takes an element with id root to be its base element for rendering all the UIs.
Like in vanilla JS, React searches for an element with an ID 'root' and keeps all the UI to be rendered inside that element using the virtual DOM concept.
After you complete the React development, you have to use a build tool to build a React app by npm build or yarn build, which merges all your codes into a single file. So when a client requests your site, the server sends .html the JS files. So, at last, JS files manipulate the single .html file.
About the create-react-app, react-scripts package that comes when you create a react app with npx create-react-app handles all the requirements to serve a development serve using node. All the files of packages are inside node_moudles.
D - Function Component and Class Component
Functional Components
Functional components are some of the more common components that will come across while working in React. These are simply JavaScript functions. We can create a functional component to React by writing a JavaScript function.
Syntax:
const Car=()=> {
return <h2>Hi, I am also a Car!</h2>;
}

Class Component








Mayooran NavamanyPosted Sep 5, 2023, 6:54 AM
Nice article