How to write if statement in React.js?

How to write if statement in React.js?

Obviously, in the event that we consider if proclamation in Javascript or Typescript rationale, it's equivalent to in each Javascript or Typescript place. 

It's simply if/else like unadulterated javascript, however for this situation, we won't talk about the typical if/else. 

In respond, we'll need if proclamations for the one more thing, it's the delivering. 

It's named "Contingent delivering", however to make it basic, how about we remain with "if proclamation in respond". 

There are the two most mainstream approaches to utilize restrictive delivering that we'll find in the React.js code, and relies upon a case, them two are right. 

The main way that we can utilize is to characterize the contingent delivering legitimately in the segments format. 

It's brisk and simple that we'll utilize the most, and now and again, it is the best for execution. 

We'll be utilizing along these lines in the situations when we have just one condition, all the more similarly as "if", when we might want to deliver some component when a predefined condition is passed. 

The subsequent way is the capacity made to deal with indicated portions of the design, and render it restrictively, to do that we can utilize if/else however the switch case too. 

This single direction is on the whole correct to use in situations where we have more conditions, particularly the form with switch one. 

Be that as it may, it fires the capacity in any case, so it is no sense to utilize it when we have one condition. 

We should investigate the code models where I included the two different ways of doing that:

// The first example with the code inside functional component
function Parent(props) {
      {name === "CrowdforThink" && (

// The second example with the additional function
function renderComponent() {
  const name = 'CrowdforThink';
  if (name === 'CrowdforThink') {
    return 'CrowdforThink';
  } else {
    return null;

function Parent(props) {
  return renderComponent();


Author Biography.


CrowdforThink is the leading Indian media platform, known for its end-to-end coverage of the Indian startups through news, reports, technology and inspiring stories of startup founders, entrepreneurs, investors, influencers and analysis of the startup eco-system, mobile app developers and more dedicated to promote the startup ecosystem.

Join Our Newsletter.

Subscribe to CrowdforThink newsletter to get daily update directly deliver into your inbox.

CrowdforJobs is an advanced hiring platform based on artificial intelligence, enabling recruiters to hire top talent effortlessly.


CrowdforApps brings to you the well researched list of the most successful and finest App development companies, Web software developers.


CrowdforGeeks is where lifelong learners come to learn the skills they need, to land the jobs they want, to build the lives they deserve.


CrowdforThink is a leading Indian media and information platform, known for its end-to-end coverage of the Indian startup ecosystem.


News & Blogs


How to Import Components from React Bootstrap

React Bootstrap is one of the broadly utilized libraries in React, and its different parts are ut...


Do you need a React framework?

Inspiration  Respond is a JavaScript library for building UIs, yet when we need to create a...


10 ReactJS devices to support your web improvem...

Did you know most list of qualifications submitted for occupations get dismissed with only a soli...

Top Authors

Hey, I am Suraj - a full-time blogger and a social media expert currently working on the Growth H...

Suraj Kumar

Overall 3+ years of experience as a Full Stack Developer with a demonstrated history of working i...

Lokesh Gupta

With good communication and writing skiils, Astha Sharma is a full-time content writer working wi...

Astha Sharma

Zakariya has recently joined the PakWheels team as a Content Marketing Executive, shortly after g...

Zakariya Usman

Our Client Says

WhatsApp Chat with Our Support Team