0% found this document useful (0 votes)
50 views3 pages

React IP

Download as txt, pdf, or txt
Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1/ 3

//################################################ Basic

##########################################
What is React?
React is a JavaScript library used for building user interfaces. It allows
developers to create reusable UI components and efficiently update the user
interface based on changes in data.

What are the key features of React?


React has several key features, including:

Component-based architecture: React organizes the UI into reusable components,


making it easier to build and maintain complex applications.
Virtual DOM: React uses a virtual representation of the DOM, which allows for
efficient updates and improves performance.
Unidirectional data flow: React follows a one-way data binding approach, making it
easier to understand and track data changes.
What is JSX?
JSX is a syntax extension for JavaScript that allows you to write HTML-like code in
your JavaScript files. It enables you to describe the structure and appearance of
your UI components in a declarative manner.

What is the difference between React functional components and class components?
Functional components are JavaScript functions that return JSX, while class
components are ES6 classes that extend the React.Component class. Functional
components are simpler and easier to understand, while class components have
additional features like state and lifecycle methods.

What is the purpose of state in React?


State is an object that holds data specific to a component. It allows you to create
dynamic and interactive components by managing and updating data within the
component. When the state changes, React automatically re-renders the component.

What are props in React?


Props (short for properties) are a way to pass data from a parent component to its
child components. They are read-only and cannot be modified within the child
component. Props allow you to customize and configure child components based on
their parent's data.

What is the role of keys in React lists?


Keys are used to uniquely identify elements in a list of components. They help
React identify which items have changed, been added, or been removed. Keys assist
in efficient re-rendering and help improve the performance of the application.

What is the significance of the "render" method in React?


The "render" method is a required method in React components. It returns the JSX
markup that defines the component's output. The "render" method is called whenever
there is a change in the component's state or props.

What are React hooks?


React hooks are functions that allow you to use state and other React features in
functional components without writing a class. They enable you to add state and
lifecycle functionality to functional components, making them more powerful and
reusable.

What is the purpose of the useEffect hook?


The useEffect hook is used to perform side effects in functional components. Side
effects include tasks such as fetching data from an API, subscribing to event
listeners, or manually manipulating the DOM. It replaces the functionality of
lifecycle methods in class components.
#################################### ADVANCED ####################
What are React hooks and why were they introduced?
React hooks are functions introduced in React 16.8 that allow you to use state and
other React features in functional components without writing a class. They were
introduced to address the problem of code duplication and improve code reuse in
React components.

Explain the useState hook in React.


The useState hook allows functional components to have state. It returns an array
with two elements: the current state value and a function to update that value. You
can provide an initial value when calling useState, and subsequent calls to the
update function will re-render the component.

What is the useContext hook used for?


The useContext hook allows you to consume values from the React context API in
functional components. It takes a context object created by the
React.createContext() function and returns the current value of the context. It
simplifies the process of accessing context values without nesting multiple
components.

What is the useReducer hook and when should it be used?


The useReducer hook is an alternative to useState for managing complex state logic.
It accepts a reducer function and an initial state, and returns the current state
and a dispatch function to trigger state updates. It is particularly useful when
the state transitions involve multiple sub-values or have complex dependencies.

Explain the useMemo hook in React.


The useMemo hook is used to memoize expensive computations in functional
components. It takes a function and a dependency array as arguments, and returns a
memoized value. The memoized value is only recalculated when one of the
dependencies changes, improving performance by avoiding unnecessary computations.

What is React Router and how does it work?


React Router is a popular library used for routing in React applications. It allows
you to define different routes in your application and render different components
based on the current URL. React Router uses a combination of components and a
declarative configuration to handle navigation and rendering of components.

What is Redux, and how does it work with React?


Redux is a predictable state management library that can be used with React (though
it can be used independently as well). Redux helps manage the state of an
application in a centralized store, and React components can access the state and
trigger actions to modify it. Redux works well with React by using the react-redux
library to connect components to the Redux store.

Explain the concept of React context.


React context provides a way to share data between components without passing props
through intermediate components. It allows you to create a context object using
React.createContext(), provide a value to the context using a provider component,
and access the value in child components using the useContext hook or context
consumer component.

What is server-side rendering (SSR) in React, and why is it beneficial?


Server-side rendering is the process of rendering React components on the server
and sending the pre-rendered HTML to the client. This approach improves the initial
loading time and enhances search engine optimization (SEO) because search engine
crawlers can easily read the content. It provides a better user experience,
especially for slower network connections.
What are React portals used for?
React portals allow you to render a component's content in a different DOM node
outside of its parent component's hierarchy. It is useful when you need to render a
component at a higher level in the DOM hierarchy, such as creating modal dialogs or
tooltips that need to appear on top of other elements.

You might also like