React Questions
Warm up for your React interview with most asked questions and answers for junior, mid, and senior roles.
What are forward refs?
Show AnswerHide Answer
Forward refs are a way to reference a component that is not yet defined. You can use forward refs to reference components that are defined later in your code.
Explain the term reconciliation
Show AnswerHide Answer
Reconciliation is the process of comparing the current state of the component with the previous state and updating the component to reflect the new state.
What are synthetic events in React?
Show AnswerHide Answer
A synthetic event is a cross-browser wrapper around the browser's native event. It has the same interface as the browser's native event, including stopPropagation() and preventDefault() , except the events work identically across all browsers.
What is Flux Concept In React?
Show AnswerHide Answer
Flux is an architecture for creating data layers in JavaScript applications. It was designed on Facebook along with the React view library.
It places a focus on creating explicit and understandable update paths for your application's data, which makes tracing changes during development simpler and makes bugs easier to track down and fix.
What are reacted portals?
Show AnswerHide Answer
React portals are a way to render a child component inside a DOM node that is outside the React tree. This is useful for rendering a dialog or a tooltip inside a table or a tree.
What is the difference between ShadowDOM and VirtualDOM?
Show AnswerHide Answer
Virtual DOM is a copy of the whole DOM object.
On the other hand, Shadow DOM creates small pieces of the DOM object which has isolated scope for the element they represent.
Does React useState Hook update immediately?
Show AnswerHide Answer
useState creates queues for React core to update the state object of a React component. So the process to update React state is asynchronous for performance reasons.
Explain why and when would you use useMemo()?
Show AnswerHide Answer
useMemo is a React hook that allows you to memoize the return of expensive functions, avoiding calling them on every render.
Does React re-render all components and sub components every time setState is called?
Show AnswerHide Answer
React re-renders all components and sub components every time setState is called.