Top 10 React Interview Questions — 2021

CodeyMaze
2 min readMar 5, 2022

This comprehensive list of React questions is going to help you crack your next job interview. Go through these questions once before you give your interview.

What are props in react?

Props are like parameters passed to a function. Using props helps us to pass data from parent component to child component.

Can child component change the props passed from parent component?

No, Whether it is a class component or function component, props can never be updated in the child component.

What is state?

The state is like a local variable in the component, which cannot be accessed outside the component. Updating the state in the component cause re-rendering of the component.

Can we use props inside functional components?

Yes, In class components props can be accessed with this.props but in functional components, we can use props only.

Is it necessary to have state in each component of React?

No, it is not necessary to have state in each component of React. We can have stateless components & stateful components.

is setState function asynchronous?

yes, the setState function is asynchronous.

What is the difference between super() & super(props) in React?

When we have to use this.props inside constructor function, we have to pass props to the super function.

What are hooks used for in React?

Hooks allow us to use state and other features of class components inside functional components. For ex. to use state inside functional components, we can make use of the useState hook.

How to prevent child component from re-rendering?

We can use the shouldComponentUpdate method or can use pure components in the case of class components. In functional components, we can make use of React.memo hook.

What are pure components in React?

Pure components implements the shouldComponentUpdate() method by default. It performs a shallow comparison of the previous state and the new state before updating the component.

Visit more tutorials at https://codeymaze.com

Subscribe to our Youtube channel for more videos :

https://www.youtube.com/channel/UCEXWe9R6-ppk4zhNo2JbtmQ

--

--

CodeyMaze

I am here to provide programming related topics, running website also named http://codeymaze.com. Feel free to follow me :)