MOST COMMON
REACTJS
INTERVIEW QUESTIONS
How would you optimize your app's
performance ?
SlobodanGajić SWIPE
Lazy Loading
It is a new function in React that lets you load React
components lazily through code splitting without help
from any additional libraries.
It is a technique used to reduce the load time of a React
app.
Lazy loading helps reduce the risk of web app
performances to minimal.
SWIPE
useMemo( )
It is a React hook that is used for caching CPU-Expensive
functions.
Sometimes in a your app, a CPU-Expensive function gets
called repeatedly due to re-renders of a component, which
can lead to slow rendering.
useMemo( ) hook can be used to cache such functions. By
using useMemo( ), the CPU-Expensive function gets called
only when it is needed.
SWIPE
React.PureComponent
Instead of using the simple React.Component, we can use
React.PureComponent to reduce the re-renders of a
component unnecessarily.
The difference between them is that React.Component
doesn’t implement shouldComponentUpdate(), but
React.PureComponent implements it with a shallow prop
and state comparison.
SWIPE
Maintaining State Colocation
This is a process of moving the state as close to where
you need it as possible.
Sometimes in React app, we have a lot of unnecessary
states inside the parent component which makes the code
less readable and harder to maintain.
Not to forget, having many states inside a single
component leads to unnecessary re-renders for the
component.
It is better to shift states which are less valuable to the
parent component, to a separate component.
SWIPE
Would you add
anything??
LET ME KNOW IN THE COMMENTS
SlobodanGajić SlobodanGajic