REACT JS
What is React JS ?
React is a free open source javascript library used for building User Interfaces or UI Components. It is developed by Facebook, specifically by a software engineer named Jordan Walke. React was first deployed on Facebook’s news feed in 2011 and was open-sourced at the JavaScript Conference (JSConf) in May 2013. The reason for the development of React was driven by the need to address specific challenges in building dynamic and high-performance web applications. Nowadays React has become one of the most popular libraries for building modern web applications, widely adopted by both startups and large enterprises. Its influence has also extended beyond web development with the introduction of React Native for mobile app development.
What is the use of React Js ?
As user interfaces became more dynamic and complex, managing updates to the DOM in a performant and efficient manner became more difficult and complex. Traditional methods of updating the UI were inefficient and had performance issues. As a result React’s virtual DOM concept was introduced to address these issues by allowing for efficient updates and rendering. By abstracting the complex DOM manipulations and enabling developers to describe the UI in a declarative manner using JSX, React also improved developer productivity and reduced bugs. React’s component-based architecture was designed to improve code reusability and modularity, making it easier to manage and scale large applications.
Basic fundementals of React
Components
A Component is considered as the core building blocks of a React application. Components makes the task of building UIs much easier. Each component exists in the same space, but they work independently from one another and merge all in a parent component, which will be the final UI of your application. Every React component have their own structure, methods as well as APIs. They can be reusable as per your need.
I. Functional Components
Function components are simply JavaScript functions that may or may not receive data as parameters. It is a way to write components that only contain a render method and don’t have their own state.
II. Class Components
A class component can show inheritance and access data of other components. Class Component must include the line “extends React.Component” to pass data from one class component to another class component. We can use JavaScript ES6 classes to create class-based components in React.
JSX (JavaScript XML)
JSX a syntax extension for JavaScript that lets you write HTML-like markup inside a JavaScript code. JSX allows us to write HTML elements in JavaScript and place them in the DOM without any createElement() and/or appendChild() methods. JSX converts HTML tags into react elements. JSX helps us keep our code simpler and elegant when writing large pieces of code.
Props (Properties)
Props are arguments passed into React components via HTML attributes. React Props are like function arguments in JavaScript and attributes in HTML. It is an object which stores the value of attributes of a tag and work similar to the HTML attributes. It is an object which stores the value of attributes of a tag and work similar to the HTML attributes.
State
State is a way to store and manage the information or data while creating a React Application. The state is a JavaScript object that contains the real-time data or information of a component. A component’s state can change over time; whenever it changes, the component re-renders.
Lifecycle Methods
React Lifecycle the series of methods that are invoked in different stages of the component’s existence. It starts from its initialization and ends when it is unmounted from the DOM. There are three categories of lifecycle methods.
Get Thamalu Amarasingha’s stories in your inbox
Join Medium for free to get updates from this writer.
I. Mounting
Mounting means putting elements into the DOM.
II. Updating
A component is updated whenever there is a change in the component’s “state” or “props”.
III. Unmounting.
A component is removed from the DOM, or unmounting.
Hooks
Hooks allow function components to have access to state and other React features. Because of this, class components are generally no longer needed.
Event Handling
A fundamental to understanding how React processes browser events and updates the DOM. An event is an action that could be triggered as a result of the user action or system generated event.
Conditional Rendering
Components will often need to display different things depending on different conditions. It is done using JavaScript operators like “if” or the conditional operator to create elements representing the current state, and React will update the UI to match them.
Lists and Keys
A “key” is a special string attribute you need to include when creating lists of elements in React. Keys are used in React to identify which items in the list are changed, updated, or deleted. Keys are used to give an identity to the elements in the lists.
Forms
Forms are an essential role in modern web applications. Forms enable users to share information, complete tasks and provide feedback. An input form element whose value is controlled by React in this way is called a “controlled component”.
Routing (with React Router)
Routing is the process of navigating between different pages without triggering a full page reload. React Router is a library use in React for routing. It enables the navigation among views of various components in a React Application, allows changing the browser URL, and keeps the UI in sync with the URL.




