Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

What Is React

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

What is React?

List some of the major advantages of React.

How do you handle security in a React application?

What do you understand by Virtual DOM? Explain its works.

Differentiate between Real DOM and Virtual DOM.

What is a React hook?

Name some built-in hooks in React.

What is the difference between useState and useEffect?

What is Props?

What is a state in React and how is it used?

Differentiate between states and props.

Differentiate between stateful and stateless components.

Explain the lifecycle methods of React components in detail.

i. componentWillMount() – Executed just before rendering takes place both on the client as
well as server-side.
ii. componentDidMount() – Executed on the client side only after the first render.
iii. componentWillReceiveProps() – Invoked as soon as the props are received from the parent
class and before another render is called.
iv. shouldComponentUpdate() – Returns true or false value based on certain conditions. If you
want your component to update, return true else return false. By default, it returns false.
v. componentWillUpdate() – Called just before rendering takes place in the DOM.
vi. componentDidUpdate() – Called immediately after rendering takes place.
vii. componentWillUnmount() – Called after the component is unmounted from the DOM. It is
used to clear up the memory spaces.

What is Redux?

What are the three principles that Redux follows?

i. Single source of truth: The state of the entire application is stored in an object/ state tree
within a single store. The single state tree makes it easier to keep track of changes over time
and debug or inspect the application.
ii. State is read-only: The only way to change the state is to trigger an action. An action is a
plain JS object describing the change. Just like state is the minimal representation of data, the
action is the minimal representation of the change to that data.
iii. Changes are made with pure functions: In order to specify how the state tree is
transformed by actions, you need pure functions. Pure functions are those whose return value
depends solely on the values of their arguments.

List down the components of Redux.


Redux is composed of the following components:

i. Action – It’s an object that describes what happened.


ii. Reducer – It is a place to determine how the state will change.
iii. Store – State/ Object tree of the entire application is saved in the Store.
iv. View – Simply displays the data provided by the Store.

What are the advantages of Redux?

Advantages of Redux are listed below:

 Predictability of outcome – Since there is always one source of truth, i.e. the store, there is
no confusion about how to sync the current state with actions and other parts of the
application.
 Maintainability – The code becomes easier to maintain with a predictable outcome and strict
structure.
 Server-side rendering – You just need to pass the store created on the server, to the client
side. This is very useful for initial render and provides a better user experience as it optimizes
the application performance.
 Developer tools – From actions to state changes, developers can track everything going on
in the application in real time.
 Community and ecosystem – Redux has a huge community behind it which makes it even
more captivating to use. A large community of talented individuals contribute to the betterment
of the library and develop various applications with it.
 Ease of testing – Redux’s code is mostly functions which are small, pure and isolated. This
makes the code testable and independent.
 Organization – Redux is precise about how code should be organized, this makes the code
more consistent and easier when a team works with it

What is the difference between a stateless component and a stateful component in React?

How do you handle performance optimization in a React application?

There are several ways to optimize the performance of a React application, including:

 Using the shouldComponentUpdate lifecycle method to prevent unnecessary re-renders of


components.
 Using React’s built-in PureComponent or implementing a custom shouldComponentUpdate
method to optimize performance for functional components.
 Using the React developer tools to profile the application and identify performance
bottlenecks.
 Using the React.memo method for functional components
 Using React’s Context API instead of props drilling.
 Using the useEffect hook to handle side effects in functional components.
 Using the useCallback and useMemo hooks to prevent unnecessary re-renders and improve
performance.
 Lazy loading of components and code splitting.
 Minimizing the number of DOM updates by using the key prop when rendering a list of items.
 Using the useReducer hook to manage state updates instead of useState
 Using a virtualized list library like react-virtualized, react-window etc.
 It’s always a good idea to test performance with real-world use cases and user interactions
before and after making any optimization.*
 What is node js
 Architecture of it

What is middleware in Node.js and how is it used?


What is RESTful API?
What is MongoDB?
How to Connect Node.js to a MongoDB Database?
How node ract mongodb works and communicate

You might also like