Every react developer must know!

Akbor Hossain Rifat
4 min readNov 4, 2020

What is React Js?

React JS is a JavaScript library used in net improvement to construct interactive factors on websites. But if you’re now not acquainted with JavaScript or JavaScript libraries, that’s no longer a useful definition. So let’s take a step again and deal with these phrases first

Why Do Use React JS?

React is a JavaScript library that specializes in supporting builders construct person interfaces or UIs. In phrases of web sites and internet applications, as are the series of on-screen menus, search bars, buttons, and whatever else anyone interacts with to USE an internet site or app.

In addition to providing reusable React library code (saving development time and cutting down on the chance for coding errors), React comes with two key features that add to its appeal for JavaScript developers

  1. JSX

2. Virtual DOM

What is JSX?

At the coronary heart of any simple internet site are HTML documents. Web browsers examine these archives and show them on your computer, tablet, or telephone as net pages. During this process, browsers create something referred to as a Document Object Model (DOM), a representational tree of how the internet web page is arranged. Developers can then add dynamic content material to their initiatives by using editing the DOM with languages like JavaScript.

JSX (short for JavaScript eXtension) is a React extension that makes it handy for internet builders to regulate their DOM by using the usage of simple, HTML-style code. And — since React JS browser assists extend to all current net browsers — JSX is well suited with any browser platform you may be working with.

This isn’t simply a be counted of convenience, though — using JSX to replace a DOM leads to full-size web page overall performance enhancements and improve efficiency. How? It’s all about the subsequent React feature, the Virtual DOM.

What is Virtual DOM?

If you’re now not the use of React JS (and JSX), your internet site will use HTML to replace its DOM (the manner that makes matters “change” on display except a person having to manually refresh a page). This works pleasant for simple, static websites, however, for dynamic web sites that contain heavy person interaction, it can emerge as a hassle (since the whole DOM wants to reload each and every time the consumer clicks a function calling for a web page refresh).

However, if a developer makes use of JSX to manipulate and replace its DOM, React JS creates something referred to as a Virtual DOM. Virtual DOM (like the title implies) is a reproduction of the site’s DOM, and React JS makes use of this reproduction to see what components of the genuine DOM want to alternate when a tournament occurs (like a consumer clicking a button).

Let’s say a person enters a remark in a weblog put up the shape and pushes the “Comment” button. Without the use of React JS, the complete DOM would have to replace to replicate this trade (using the time and processing electricity it takes to make this update). React, on the different hand, scans the Virtual DOM to see what modified after a consumer motion (in this case, a remark is added) and selectively updates that area of the DOM solely

Default props:

Default props. default props is a property in the React element used to set default values for the props argument. It will be modified if the prop property is passed. Default props can be described as a property on the aspect category itself, to set the default props for the class.

What is proptypes?

PropTypes are a mechanism to make sure that elements use the right statistics kind and pass by the proper data, and that aspects use the proper kind of props, and that receiving elements get hold of the proper kind of props.

We can assume of it like a doggy being delivered to a pet store. The pet keep doesn’t choose pigs, lions, frogs, or geckos — it wishes puppies. PropTypes make certain that the right records kind (puppy) is delivered to the pet store, and no longer some different type of animal.

In the area above, we noticed how to bypass data to any factor the use of props. We handed props immediately as an attribute to the component, and we additionally surpassed props from the backyard of the factor and used them in that component. But we didn’t take a look at what kind of values we are getting in our issue thru props or that the whole thing nevertheless works.

It’s definitely upon us whether or not to validate the facts we get in an element thru props. But in a complicated application, it is usually a proper exercise to validate that data.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Akbor Hossain Rifat
Akbor Hossain Rifat

Written by Akbor Hossain Rifat

Hi There, MERN-Stack ,JavaScript ,TypeScript , React.js , Node.js , MongoDB , MySQL , WordPress Developer. Simplifying fullStack development for you.

No responses yet

Write a response