
Domains
Agile Management
Master Agile methodologies for efficient and timely project delivery.
View All Agile Management Coursesicon-refresh-cwCertifications
Scrum Alliance
16 Hours
Best Seller
Certified ScrumMaster (CSM) CertificationScrum Alliance
16 Hours
Best Seller
Certified Scrum Product Owner (CSPO) CertificationScaled Agile
16 Hours
Trending
Leading SAFe 6.0 CertificationScrum.org
16 Hours
Professional Scrum Master (PSM) CertificationScaled Agile
16 Hours
SAFe 6.0 Scrum Master (SSM) CertificationAdvanced Certifications
Scaled Agile, Inc.
32 Hours
Recommended
Implementing SAFe 6.0 (SPC) CertificationScaled Agile, Inc.
24 Hours
SAFe 6.0 Release Train Engineer (RTE) CertificationScaled Agile, Inc.
16 Hours
Trending
SAFe® 6.0 Product Owner/Product Manager (POPM)IC Agile
24 Hours
ICP Agile Certified Coaching (ICP-ACC)Scrum.org
16 Hours
Professional Scrum Product Owner I (PSPO I) TrainingMasters
32 Hours
Trending
Agile Management Master's Program32 Hours
Agile Excellence Master's ProgramOn-Demand Courses
Agile and ScrumRoles
Scrum MasterTech Courses and Bootcamps
Full Stack Developer BootcampAccreditation Bodies
Scrum AllianceTop Resources
Scrum TutorialProject Management
Gain expert skills to lead projects to success and timely completion.
View All Project Management Coursesicon-standCertifications
PMI
36 Hours
Best Seller
Project Management Professional (PMP) CertificationAxelos
32 Hours
PRINCE2 Foundation & Practitioner CertificationAxelos
16 Hours
PRINCE2 Foundation CertificationAxelos
16 Hours
PRINCE2 Practitioner CertificationSkills
Change ManagementMasters
Job Oriented
45 Hours
Trending
Project Management Master's ProgramUniversity Programs
45 Hours
Trending
Project Management Master's ProgramOn-Demand Courses
PRINCE2 Practitioner CourseRoles
Project ManagerAccreditation Bodies
PMITop Resources
Theories of MotivationCloud Computing
Learn to harness the cloud to deliver computing resources efficiently.
View All Cloud Computing Coursesicon-cloud-snowingCertifications
AWS
32 Hours
Best Seller
AWS Certified Solutions Architect - AssociateAWS
32 Hours
AWS Cloud Practitioner CertificationAWS
24 Hours
AWS DevOps CertificationMicrosoft
16 Hours
Azure Fundamentals CertificationMicrosoft
24 Hours
Best Seller
Azure Administrator CertificationMicrosoft
45 Hours
Recommended
Azure Data Engineer CertificationMicrosoft
32 Hours
Azure Solution Architect CertificationMicrosoft
40 Hours
Azure DevOps CertificationAWS
24 Hours
Systems Operations on AWS Certification TrainingAWS
24 Hours
Developing on AWSMasters
Job Oriented
48 Hours
New
AWS Cloud Architect Masters ProgramBootcamps
Career Kickstarter
100 Hours
Trending
Cloud Engineer BootcampRoles
Cloud EngineerOn-Demand Courses
AWS Certified Developer Associate - Complete GuideAuthorized Partners of
AWSTop Resources
Scrum TutorialIT Service Management
Understand how to plan, design, and optimize IT services efficiently.
View All DevOps Coursesicon-git-commitCertifications
Axelos
16 Hours
Best Seller
ITIL 4 Foundation CertificationAxelos
16 Hours
ITIL Practitioner CertificationPeopleCert
16 Hours
ISO 14001 Foundation CertificationPeopleCert
16 Hours
ISO 20000 CertificationPeopleCert
24 Hours
ISO 27000 Foundation CertificationAxelos
24 Hours
ITIL 4 Specialist: Create, Deliver and Support TrainingAxelos
24 Hours
ITIL 4 Specialist: Drive Stakeholder Value TrainingAxelos
16 Hours
ITIL 4 Strategist Direct, Plan and Improve TrainingOn-Demand Courses
ITIL 4 Specialist: Create, Deliver and Support ExamTop Resources
ITIL Practice TestData Science
Unlock valuable insights from data with advanced analytics.
View All Data Science Coursesicon-dataBootcamps
Job Oriented
6 Months
Trending
Data Science BootcampJob Oriented
289 Hours
Data Engineer BootcampJob Oriented
6 Months
Data Analyst BootcampJob Oriented
288 Hours
New
AI Engineer BootcampSkills
Data Science with PythonRoles
Data ScientistOn-Demand Courses
Data Analysis Using ExcelTop Resources
Machine Learning TutorialDevOps
Automate and streamline the delivery of products and services.
View All DevOps Coursesicon-terminal-squareCertifications
DevOps Institute
16 Hours
Best Seller
DevOps Foundation CertificationCNCF
32 Hours
New
Certified Kubernetes AdministratorDevops Institute
16 Hours
Devops LeaderSkills
KubernetesRoles
DevOps EngineerOn-Demand Courses
CI/CD with Jenkins XGlobal Accreditations
DevOps InstituteTop Resources
Top DevOps ProjectsBI And Visualization
Understand how to transform data into actionable, measurable insights.
View All BI And Visualization Coursesicon-microscopeBI and Visualization Tools
Certification
24 Hours
Recommended
Tableau CertificationCertification
24 Hours
Data Visualization with Tableau CertificationMicrosoft
24 Hours
Best Seller
Microsoft Power BI CertificationTIBCO
36 Hours
TIBCO Spotfire TrainingCertification
30 Hours
Data Visualization with QlikView CertificationCertification
16 Hours
Sisense BI CertificationOn-Demand Courses
Data Visualization Using Tableau TrainingTop Resources
Python Data Viz LibsCyber Security
Understand how to protect data and systems from threats or disasters.
View All Cyber Security Coursesicon-refresh-cwCertifications
CompTIA
40 Hours
Best Seller
CompTIA Security+EC-Council
40 Hours
Certified Ethical Hacker (CEH v12) CertificationISACA
22 Hours
Certified Information Systems Auditor (CISA) CertificationISACA
40 Hours
Certified Information Security Manager (CISM) Certification(ISC)²
40 Hours
Certified Information Systems Security Professional (CISSP)(ISC)²
40 Hours
Certified Cloud Security Professional (CCSP) Certification16 Hours
Certified Information Privacy Professional - Europe (CIPP-E) CertificationISACA
16 Hours
COBIT5 Foundation16 Hours
Payment Card Industry Security Standards (PCI-DSS) CertificationOn-Demand Courses
CISSPTop Resources
Laptops for IT SecurityWeb Development
Learn to create user-friendly, fast, and dynamic web applications.
View All Web Development Coursesicon-codeBootcamps
Career Kickstarter
6 Months
Best Seller
Full-Stack Developer BootcampJob Oriented
3 Months
Best Seller
UI/UX Design BootcampEnterprise Recommended
6 Months
Java Full Stack Developer BootcampCareer Kickstarter
490+ Hours
Front-End Development BootcampCareer Accelerator
4 Months
Backend Development Bootcamp (Node JS)Skills
ReactOn-Demand Courses
Angular TrainingTop Resources
Top HTML ProjectsBlockchain
Understand how transactions and databases work in blockchain technology.
View All Blockchain Coursesicon-stop-squareBlockchain Certifications
40 Hours
Blockchain Professional Certification32 Hours
Blockchain Solutions Architect Certification32 Hours
Blockchain Security Engineer Certification24 Hours
Blockchain Quality Engineer Certification5+ Hours
Blockchain 101 CertificationOn-Demand Courses
NFT Essentials 101: A Beginner's GuideTop Resources
Blockchain Interview QsProgramming
Learn to code efficiently and design software that solves problems.
View All Programming Coursesicon-codeSkills
Python CertificationInterview Prep
Career Accelerator
3 Months
Software Engineer Interview PrepOn-Demand Courses
Data Structures and Algorithms with JavaScriptTop Resources
Python TutorialWeb Development
4.5 Rating 55 Questions 30 mins read6 Readers

Controlled components are React components that control their state via props. The state of the form elements is handled by React rather than the DOM.
Example:
class ControlledComponent extends React.Component { constructor(props) { super(props); this.state = { value: '' }; } handleChange = (event) => { this.setState({ value: event.target.value }); } render() { return ( <input type="text" value={this.state.value} onChange={this.handleChange} /> ); } }
Uncontrolled components rely on the DOM to maintain their state. You can access the current value of the element using refs.
Example:
class UncontrolledComponent extends React.Component { constructor(props) { super(props); this.inputRef = React.createRef(); } handleSubmit = (event) => { event.preventDefault(); alert(this.inputRef.current.value); } render() { return ( <form onSubmit={this.handleSubmit}> <input type="text" ref={this.inputRef} /> <button type="submit">Submit</button> </form> ); } }
Key is a special string attribute we need to include when creating lists of elements. Keys help React identify which items have changed, are added, or are removed.
Example:
const listItems = items.map((item) => <li key={item.id}>{item.name}</li> );
Forms in React can be handled by using controlled components where the component's state handles form data.
Example:
class MyForm extends React.Component { constructor(props) { super(props); this.state = { name: '' }; } handleChange = (event) => { this.setState({ name: event.target.value }); } handleSubmit = (event) => { event.preventDefault(); alert('A name was submitted: ' + this.state.name); } render() { return ( <form onSubmit={this.handleSubmit}> <label> Name: <input type="text" value={this.state.name} onChange={this.handleChange} /> </label> <input type="submit" value="Submit" /> </form> ); } }
You can conditionally render components using JavaScript conditional statements like if, else, or ternary operators within JSX.
Example:
const MyComponent = ({ isLoggedIn }) => { return ( <div> {isLoggedIn ? <h1>Welcome back!</h1> : <h1>Please sign in.</h1>} </div> ); }
React or simply React is a frontend library created by Facebook. It is used in their products like Facebook, WhatsApp, and Instagram. It was initially maintained by Facebook but later it was made open source and now have an active developer community. Popular websites like Netflix, Airbnb, Yahoo! Mail, KhanAcademy, Dropbox and much more use React to build their UI.
React allow us to create reusable UI components. Suppose you have a website, which has the same header and footer in all pages. If you create it using normal HTML and JS, then you have to use the same HTML code for header and footer in all pages. But in React you can have the Header and Footer as a separate component and import it into different Pages.
Consider this React code for About Us page.
import React from ‘react’;
import Header from ‘./HeaderPage’;
import Footer from ‘./FooterPage’;
const AboutPage =() => {
return(
<div>
<Header />
<h1>About Us</h1>
<p>We are a cool web development company,
located in Silicon Valley.</p>
<Footer />
</div>
)
};
export default AboutPage;
Now, Consider this React code for Services page.
import React from ‘react’;
import Header from ‘./HeaderPage’;
import Footer from ‘./FooterPage’;
const ServicePage =() => {
return(
<div>
<Header />
<h1>Services</h1>
<p>We provide service in Web development, Mobile
development, SEO services.</p>
<Footer />
</div>
)
};
export default ServicePage;
Beside this React is also very fast which reduces the loading time of even complex web-apps. React achieves this speed because it doesn’t update the Real DOM directly but it updates the Virtual DOM.
There are mainly two ways to start a project in React - First is to setup React with Webpack and Babel from Scratch. The second way is to use the user-friendly way provide by Facebook ie using create-react-app.
The create-react-app also under the hood uses babel and webpack to compile your React code to plain HTML, CSS, and JavaScript. So, we can set them manually in React. But it is a lengthy and complicated process.
On the other hand, create-react-app is a simple way to start with React and provided by Facebook. The way is a bit different for npm version 5.2 and up then for 5.1 and down.

We will look into the way to create a react app using rpm version 5.2+. So, first, go to your terminal to check your npm version.
As I have npm version 6.5, so will use npx create-react-app my-app to create the react app.
It will take some time to install all the dependencies from the internet. It will take 2-4 minutes.


It will show us the above message once the system is ready. Next we cd into the directory and run our local development environment by running npm start
If it compiled successfully, we will get the below in our terminal.
As instructed, we need to open any web browser and go to http://localhost:3000/ to see our React app.

If you use npm 5.1 or earlier, you can't use npx. Instead, install create-react-app globally:
npm install -g create-react-app Now you can run: create-react-app my-app

A common question in Reactjs interview questions, don't miss this one.
MVC or Model-View-Controller is a software design pattern mainly used in Web development for creating complex web-apps. This architecture comes from the traditional flow of web-application:
Now, React is considered as the View layer in the MVC model, as it is mainly used to create the UI.
To use Controller and Model logic in React, we use third party libraries like flux and Redux with it.
One of the most frequently posed interview questions on React, be ready for it.
Both Angular and React are popular JavaScript Framework/Library used worldwide to create complex web-apps.
Angular is different then AngularJS, which was released in 2009 and uses JavaScript. Angular released in 2016 by Google, was a complete rewrite of AngularJS and is not backward compatible. It uses TypeScript instead of JavaScript as the programming language. TypeScript is a statically typed language, which is considered as the superset of JavaScript. TypeScript provides developers with Object-oriented background a smooth transition to JavaScript.
React is a JavaScript library released by Facebook in 2013. It was initially developed at Facebook to optimise the ease of development of Component and to speed up Facebook.
Let’s now look at the differences between Angular and React -
Angular is a complete framework, whereas React is a library. React is very lightweight and we generally use other third-party libraries to enhance its capabilities when required. On the other hand, you get everything inside the Angular ecosystem only, but sometimes its an overkill.
Angular uses two-way data-binding, whereas React uses one-way data-binding. In React the data flows from parent component to child component only. Sometimes this complicates thing and to solve it we use state management packages like Redux and Flux with it.
Angular comes with complete MVC(Model-View-Controller), whereas React is just the View layer in MVC. In Angular, we write our TypeScript and HTML in different files and it separates the logic. Whereas in React, we use a hybrid language called JSX, which is basically writing JavaScript inside HTML code.
React is faster than Angular because it updates the Virtual DOM, whereas Angular updates directly the Real DOM. React only updates the part of DOM which gets updated by the code and behind the scene updates the Real DOM, when its efficient, Angular directly updates Real DOM, like a typical vanilla HTML, JS application. This has a huge impact in complex web-applications which have many complex features and it gives the advantage to React.
React is much easier to learn for a beginner as it’s a library with some basic concept. In comparison, Angular learning curve is more as you have to learn a complete Framework and have many unique concepts. But once you need to implement things like Redux, react-router to React, the complexity grows.
JSX is used in React to write code instead of regular JavaScript. It is similar to JavaScript but actually an extension to it. JSX Allows us to include ‘HTML’ in the same file along with ‘JavaScript’ (HTML+JS=JSX).
JSX looks like regular HTML and we have used it in Question 1.
import React from ‘react’;
import Header from ‘./HeaderPage’;
import Footer from ‘./FooterPage’;
const AboutPage =() => {
return(
<div>
<Header />
<h1>About Us</h1>
<p>We are a cool web development company,
located in Silicon Valley.</p>
<Footer />
</div>
)
};
export default AboutPage;In the above example inside the return statement, we are using JSX. Notice, the <div> is used to wrap the whole HTML code. It is required or else compiler will throw an error.
JavaScript expressions also can be used inside of JSX. We use it by wrapping them inside a set of curly brackets {}, as in below example.
import React from ‘react’;
const DemoPage =() => {
return(
<div>
<h1>{1+1}</h1>
</div>
)
};
export default DemoPage;Gives output - 2
We cannot use if-else statement inside JSX, so we use ternary expressions if we need to check condition. In the below example, we took the App.js provided when we create a react app using create-react-app. Here we modified the code and used a ternary expression to check if i is 1, and then display an image or else display the link.
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
class App extends Component {
render() {
var i =1;
return (
<div className="App">
<header className="App-header">
{ i === 1 ?
<img src={logo} className="App-logo" alt="logo" /> :
<a href="https://reactjs.org" target="_blank">
Learn React
</a>
}
</header>
</div>
);
}
}
export default App;Gives output -

import React from "react";
import ReactDOM from "react-dom";
import "./styles.css";
function Button(props) {
return (
<button type="submit">{props.label}</button>
);
}
const rootElement = document.getElementById("root");
ReactDOM.render(<Button label="Save" />, rootElement);import React from "react";
import ReactDOM from "react-dom";
import "./styles.css";
function App() {
const check = 0; // 0, "", null, undefined
return (
<div className="App">
{ check && <span>Hello</span> }
</div>
);
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);This will render 0 to the browser.
We need to make the 0 a Boolean by adding !. Code is given below
import React from "react";
import ReactDOM from "react-dom";
import "./styles.css";
function App() {
const check = 0; // 0, "", null, undefined
return (
<div className="App">
{ !check && <span>Hello</span> }
</div>
);
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);This is a frequently asked question in React interview questions for experienced.
React router is a commonly used module for routing in React applications.
React router component listens to history changes in React applications. It has a URL mapping to components in it. It renders the corresponding component when a match is found.
Link component is used to navigate around in your application.
Code sample below
import React from "react";
import ReactDOM from "react-dom";
import "./styles.css";
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
const App = () => (
<Router>
<>
<Link to="/">Home</Link> <Link to="/page">Page</Link>
<Route exact path="/" component={Home} />
<Route path="/page" component={Page} />
</>
</Router>
)
const Home = () => <h2>Home</h2>;
const Page = () => <h2>Page</h2>;
const rootElement = document.getElementById("root");
ReactDOM.render(<App label="Save" />, rootElement);import React from "react";
import ReactDOM from "react-dom";
import "./styles.css";
function App() {
return (
[
<p>one</p>,
<p>two</p>
]
);
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);Expect to come across this popular question in React interview questions.