ReactJs Framework

Introduction to ReactJs

Chathuranga Dissanayake
3 min readMay 14, 2022

React is a front-end JavaScript library for creating user interfaces using UI components that are free and open-source and Jordan Walke, a Facebook software engineer came up with the idea. It’s a component-based front-end library that’s only responsible for the application’s view layer.

React Lifecycle

React component has a lifecycle that you can track and change via its three stages: Mounting, Updating, and Unmounting.

1. Mounting

Mounting is the process of adding elements to the DOM.

React calls the below four built-in functions when mounting a component.

· constructor()

· getDerivedStateFromProps()

· render()

· componentDidMount()

2. Updating

The lifecycle moves on to the next stage after a component is updated.

When a component’s state or props change, the component is updated.

React executes the following five built-in functions in this order when a component is changed:

· getDerivedStateFromProps()

· shouldComponentUpdate()

· render()

· getSnapshotBeforeUpdate()

· componentDidUpdate()

3. Unmounting

When a component is unmounted, or deleted from the DOM as React calls it.

componentWillUnmount() calls when a component is unmounted.

Steps to set up a ReactJs project.

The command “npx create-react-app” creates a React Boilerplate which is an open-source development tool, use to reduce development time. The below image shows a basic ReactJs Boilerplate.

Structure of the Boilerplate

“npm start” command runs the node script that is listed under start in the package. json.

What is package.json?

· Package.json keeps track of key project metadata that is required when publishing to npm.

· It also describes the project’s functional properties, which npm uses to install dependencies.

Why you should use ReactJs to develop your project.

Speed -: ReactJs simply allows developers to use separate components of their application on both the client-side and the server-side, resulting in a faster development process.

Flexibility -: React code is easier to maintain and more versatile than other frontend frameworks because of its modular structure. Businesses save a significant amount of time and money as a result of this flexibility.

Performance -: The framework’s key features include a virtual DOM program and server-side rendering, allowing complicated projects to execute exceptionally quickly.

Usability -: If you have some basic JavaScript expertise, deploying React is quite simple. So, anyone who is having good knowledge in JavaScript can easily learn ReactJs.

Also, the reusability of components can get as a key benefit of the ReactJs framework as well.

Extensions to make coding easier

--

--

Chathuranga Dissanayake

Software Engineering undergraduate at Sri Lanka Institute of Information Technology | Tech Lover