Q1. What is React?
React is a JavaScript library for building user interfaces, developed by Facebook. It allows developers to create reusable UI components and manage the view layer for web and mobile apps. React uses a virtual DOM to improve performance by minimizing direct manipulation of the actual DOM.
Q2. What are the key features of React?
Key features include JSX (JavaScript XML syntax), Virtual DOM for efficient updates, component-based architecture, unidirectional data flow, and hooks for state and lifecycle management. It also supports server-side rendering and has a rich ecosystem.
Q3. What is JSX?
JSX stands for JavaScript XML. It allows you to write HTML-like code in JavaScript files. JSX makes it easier to create React elements and components. Although it looks like HTML, it is transformed into JavaScript function calls (React.createElement) by tools like Babel.
Q4. How does React work?
React works by creating a virtual DOM representation of the UI. When state or props change, React creates a new virtual DOM tree, compares it with the previous one (diffing), and efficiently updates only the changed parts in the real DOM. This makes React fast and efficient.
Q5. What is a component in React?
A component is a reusable, self-contained piece of UI. Components can be functional or class-based. They accept inputs called props and return React elements describing what should appear on the screen. Components can manage their own state and compose to build complex UIs.
