The document provides an overview of React.js, a JavaScript library for building user interfaces, highlighting its features such as JSX, Virtual DOM, and component-based architecture. It explains key concepts including props, state, React Hooks, and state management with Redux. Additionally, it covers performance optimization techniques and the use of React Router for navigation.
The document provides an overview of React.js, a JavaScript library for building user interfaces, highlighting its features such as JSX, Virtual DOM, and component-based architecture. It explains key concepts including props, state, React Hooks, and state management with Redux. Additionally, it covers performance optimization techniques and the use of React Router for navigation.
React.js is a JavaScript library for building user interfaces. It provides component-based architecture, Virtual DOM for performance, and declarative UI development.
What are the main features of React?
JSX (JavaScript XML), Virtual DOM, Component-Based Architecture, and State Management using Hooks or Redux.
What is JSX in React?
JSX is a syntax extension that allows writing HTML-like code inside JavaScript.
What is the difference between Functional and Class Components?
Functional components use Hooks for state and lifecycle management, while Class components use this.state and lifecycle methods like componentDidMount.
What is the Virtual DOM, and how does it work?
The Virtual DOM is a lightweight copy of the actual DOM. React compares it with the previous version and updates only changed parts in the real DOM.
What are props in React?
Props (properties) allow data to be passed from a parent component to a child component.
Can you modify props inside a component?
No, props are immutable and should only be read by the component that receives them.
What is state in React? How is it different from props?
State is mutable and managed within a component, while props are immutable and passed from parent to child.
What are React Hooks?
Hooks allow functional components to use state and lifecycle methods without needing class components.
What is useEffect, and how is it used?
useEffect handles side effects like API calls and DOM updates in functional components.
How does React handle state management?
React uses useState for local state, and Context API or Redux for global state management. What is Redux, and why is it used? Redux is a state management library used when multiple components need shared state, following a unidirectional data flow using actions and reducers.
How do you improve React application performance?
Use React.memo(), lazy loading, and optimize rendering with useCallback() and useMemo().
How do you fetch data in React using fetch()?
Use the fetch() method inside useEffect to make API calls and update state.
How do you handle API calls in React using Axios?
Axios simplifies API calls by handling JSON conversion and errors automatically.
What is React Router, and how does it work?
React Router allows navigation between components without reloading the page.
What is the difference between Link and NavLink in React Router?
Link is used for navigation without a full page reload, while NavLink adds an active class to highlight the current route.
What are controlled vs. uncontrolled components in React?
Controlled components use React state (useState), while uncontrolled components use DOM references (ref).
Why did you choose React.js for frontend development?
React.js is fast, scalable, and provides an extensive ecosystem with Hooks, Redux, and React Router.