Cognizant Interview Guide
Cognizant Interview Guide
1. What is React? React is an open-source JavaScript library developed by Facebook for building
user interfaces, especially single-page applications.
Key Features:
• Component-based architecture
• Virtual DOM
• One-way data binding
• JSX syntax
• What is JSX? JSX stands for JavaScript XML. It allows writing HTML inside JavaScript and makes
code easier to understand.
Example:
1. What are components in React? Components are the building blocks of a React application.
4. What is the difference between state and props? | Feature | State | Props |
|--------|-------|--------| | Mutability | Mutable | Immutable | | Ownership | Owned by component
| Passed by parent | | Usage | Internal changes | External input |
1
5. What is Virtual DOM? A lightweight copy of the real DOM. React updates the Virtual DOM first,
compares it with the previous version (diffing), and updates the actual DOM efficiently
(reconciliation).
6. What are hooks in React? Hooks are functions that let you use state and lifecycle features in
functional components.
Popular Hooks:
• useState
• useEffect
• useContext
• What is useEffect Hook? useEffect is used to perform side effects like API calls, DOM
manipulation, etc.
Example:
useEffect(() => {
fetchData();
}, []); // runs once like componentDidMount
4. What is React Router? Library used for routing in React applications. It helps in navigating
between views or components.
Example:
1. How does React handle forms? React forms handle input through state updates and handlers.
Controlled components update the state on every input change.
Example:
Would you like to add questions on advanced topics like Redux, Context API, or performance
optimization in React?