1.What is React?
- React is a JavaScript library for building user interfaces, particularly single-page applications where the user interface needs to be dynamic and responsive.
- 2.Explain the key features of React.
- React features include a virtual DOM for optimal performance, component-based architecture for reusability, JSX syntax for defining components, and unidirectional data flow through a concept known as props.
- 3.What is JSX?
- JSX (JavaScript XML) is a syntax extension for JavaScript recommended by React. It allows you to write HTML-like code in your JavaScript files, making it easier to describe the structure of React components.
- 4.What are React components?
- React components are the building blocks of a React application. They are reusable, self-contained pieces of code that manage their own state and can be composed to create complex UIs.
- 5.Explain the difference between functional components and class components.
- Functional components are stateless and are defined as JavaScript functions. Class components, on the other hand, can have local state and lifecycle methods. With the introduction of React Hooks, functional components can now also manage state.
- 6.What is state in React?
- State is a JavaScript object that represents the current state of a component. It is used to store and manage data that may change over time, causing the component to re-render.
- 7.What are props in React?
- Props (short for properties) are used to pass data from a parent component to a child component. They are immutable and help in maintaining the unidirectional flow of data in a React application.
- 8.Explain the concept of virtual DOM.
- The virtual DOM is a lightweight copy of the actual DOM. React uses it to perform efficient updates by comparing the virtual DOM with the real DOM and only making the necessary changes. This minimizes the number of direct manipulations to the actual DOM, improving performance.
- 9.What are React Hooks?
- React Hooks are functions that allow functional components to use state and lifecycle features previously available only in class components. Examples of hooks include
useStatefor managing state anduseEffectfor handling side effects in functional components. - 10.How does React Router work?
- React Router is a library for routing in React applications. It enables navigation between different components, updating the URL accordingly. It uses a component-based approach, allowing you to define routes and associated components.
- 11.What is the significance of the
useEffecthook? - The
useEffecthook in functional components is used for handling side effects, such as data fetching, subscriptions, or manually changing the DOM. It is executed after the component has rendered, and it can be used to manage side effects and clean up resources. - 12.What is an event in React?
- An event is an action that a user or system may trigger, such as pressing a key, a mouse click, etc. React events are named using camelCase, rather than lowercase in HTML. With JSX, you pass a function as the event handler, rather than a string in HTML.
- 13.How do you create a React app?
- These are the steps for creating a React app:
- Install NodeJs on the computer because we need npm to install the React library. Npm is the node package manager that contains many JavaScript libraries, including React.
- Install the create-react-app package using the command prompt or terminal.
- Install a text editor, like Visual Studio Code or Sublime Text.




Comments
Post a Comment