React Questions

Warm up for your React interview with most asked questions and answers for junior, mid, and senior roles.

Senior

What are forward refs?

Show 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.

Senior

Explain the term reconciliation

Show 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.

Senior

What are synthetic events in React?

Show 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.

Senior

What is Flux Concept In React?

Show 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.

Senior

What are reacted portals?

Show 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.

Senior

What is the difference between ShadowDOM and VirtualDOM?

Show 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.

Senior

Does React useState Hook update immediately?

Show 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.

Senior

Explain why and when would you use useMemo()?

Show Answer

useMemo is a React hook that allows you to memoize the return of expensive functions, avoiding calling them on every render.

Senior

Does React re-render all components and sub components every time setState is called?

Show Answer

React re-renders all components and sub components every time setState is called.