π Introduction
Are you preparing for a React.js interview at TCS (Tata Consultancy Services)? React remains one of the most in-demand skills in the front-end development space.
TCS often tests candidates on their understanding of core React concepts, including components, state, props, hooks, routing, and performance optimization.
This guide is your one-stop resource for mastering React interview questions specifically asked in TCS technical rounds.
It includes beginner-friendly concepts, intermediate logic, and advanced best practices.
β Covers key React fundamentals
β Includes code examples and scenarios
β Perfect for freshers, experienced devs, or TCS off-campus candidates
π Bookmark this page and revise before your TCS interview for React.js roles.
π§ Basic React.js Interview Questions
1. What is React.js?
React is a JavaScript library developed by Facebook for building interactive and dynamic user interfaces, especially single-page applications (SPAs).
2. Key Features of React
Virtual DOM
Component-based architecture
Unidirectional data flow
JSX (JavaScript XML)
Functional components with hooks
3. What is JSX?
JSX stands for JavaScript XML. It allows you to write HTML inside JavaScript code.
const greeting = <h1>Hello, React!</h1>;
4. Real DOM vs Virtual DOM
Feature | Real DOM | Virtual DOM |
---|---|---|
Update Speed | Slow | Fast (diffing + patching) |
Manipulation | Direct | Abstract layer over Real DOM |
Performance | Lower | Optimized |
5. What are Components in React?
Components are independent, reusable UI pieces. Two types:
Functional Components
Class Components
6. Difference Between Functional and Class Components
Feature | Functional Component | Class Component |
---|---|---|
State | useState Hook | this.state |
Lifecycle | useEffect Hook | componentDidMount, etc. |
Simplicity | Simpler | Verbose |
7. What are Props?
Props (short for properties) are used to pass data from parent to child components. They are read-only.
8. What is State in React?
State is used to store component data and trigger re-renders when updated.
const [count, setCount] = useState(0);
9. What are React Hooks?
Hooks allow functional components to use state and lifecycle features.
Common hooks:
useState
useEffect
useContext
10. What is useEffect?
useEffect
performs side effects like fetching data, updating the DOM, or setting up subscriptions.
useEffect(() => {
console.log("Component mounted");
}, []);
π§© Intermediate React.js Questions
11. What are Keys in React?
Keys help React identify changes in a list to optimize rendering.
{items.map(item => <li key={item.id}>{item.name}</li>)}
12. Controlled vs Uncontrolled Components
Controlled: State handled by React.
Uncontrolled: State handled by DOM.
13. What is React Router?
A library that handles routing in SPAs.
<BrowserRouter>
<Route path="/about" element={<About />} />
</BrowserRouter>
14. What is Redux?
A predictable state container for JavaScript apps.
Centralized store
Actions, Reducers
Middleware (e.g., Redux Thunk)
15. React Context vs Redux
Feature | Context API | Redux |
---|---|---|
Built-in | β | β |
Use case | Light sharing | Complex state |
Tools | useContext | Actions, Reducers, Middleware |
16. What is shouldComponentUpdate?
A lifecycle method to prevent unnecessary re-renders.
17. useMemo vs useCallback
useMemo
: Caches valuesuseCallback
: Caches functions
18. What are React Fragments?
They let you return multiple elements without extra nodes.
<>
<td>Name</td>
<td>Email</td>
</>
19. useState vs useReducer
useState: Simple state
useReducer: Complex state with logic
20. What is Code Splitting?
Breaking code into chunks that load on demand using:
const LazyComponent = React.lazy(() => import('./Component'));
π Advanced React.js Interview Questions
21. componentDidMount vs useEffect
componentDidMount
: Class componentsuseEffect(() => {}, [])
: Functional equivalent
22. What are Higher-Order Components (HOCs)?
Functions that enhance existing components.
const withLogger = Component => props => {
console.log("Logging");
return <Component {...props} />;
};
23. What are React Portals?
Allows rendering outside the root element.
ReactDOM.createPortal(<Modal />, document.getElementById('modal-root'));
24. useRef vs useState
useRef
: No re-renderuseState
: Causes re-render
25. What is React.memo?
Optimizes functional components by memoizing output.
const MemoComp = React.memo(MyComponent);
26. SSR vs CSR
Rendering | Server-Side (SSR) | Client-Side (CSR) |
---|---|---|
Performance | Better initial load | Faster navigation |
SEO | Friendly | Not ideal |
27. What are Error Boundaries?
Catch errors during rendering.
componentDidCatch(error, info) {
this.setState({ hasError: true });
}
28. What is React.lazy?
Lazy loading components:
const Home = React.lazy(() => import('./Home'));
29. useLayoutEffect vs useEffect
useLayoutEffect
: SynchronoususeEffect
: Asynchronous
30. Performance Optimization in React
Use
React.memo
,useMemo
,useCallback
Avoid inline functions in render
Implement code splitting
Optimize rendering with
shouldComponentUpdate
πΌ Behavioral and Scenario-Based Questions (TCS Specific)
1. Describe a Project You Built Using React
Project: CRM dashboard
Features: Real-time updates, charts, responsive UI
Challenges: Handling API failure, component reusability
2. How Do You Manage State in Large Applications?
Use Redux or Context API
Split global and local state
Use middleware (redux-saga/thunk)
3. How Do You Ensure Code Reusability?
Create shared UI components
Use HOCs and custom hooks
4. How Do You Debug React Apps?
React Developer Tools
Logging with console
Debugging with breakpoints
5. How Do You Handle API Calls?
Use
fetch
oraxios
Use
useEffect
to call APIHandle loading and error states
π‘ Tips to Crack TCS React.js Interviews
Master React fundamentals β Understand JSX, props, state, hooks
Practice coding challenges β Build small reusable components
Review official docs β Go through React docs
Build projects β Showcase projects on GitHub or portfolio
Mock interviews β Practice speaking clearly and explaining code
π Conclusion
React is a must-have skill for front-end developers in todayβs job market. Whether youβre preparing for an interview with TCS, Infosys, Wipro, or any MNC, this list will guide you through key React topics. From state management to performance tuning, you now have a roadmap to interview success.
Continue your preparation with these useful guides:
π Donβt forget to bookmark this guide and share it with your peers preparing for React interviews!
Β