I've gone into interviews and felt nervous, and after many, put together these questions and answers that helped me feel confident next time. Many of these questions have been asked in multiple interviews. So have a look at these questions and answers for your next interview and get ready to get a job ✊🏻.
Let's get started-
1. What are the advantages of using React?
- Great performance
- Easy to understand and read
- Makes it easier to write tests
- Reusable components
- Huge community (as it is very popular)
2. What is the state in React?
The state is the correct way of storing data in React. If you are using class-based components hen it will be an object of a set of properties. In functional components, we use something called the useState hook.
3. What are lifecycle methods?
A component’s lifecycle is the sequence of stages an instance of a component goes through in the DOM (or virtual DOM in React’s case). If you are using functional-based components (which you should) then lifecycle methods are much simplified with the useEffect hook. Instead of having multiple things like componentDidMount, componentDidUpdate, componentWillUnmount.
4. What are props and Why are they so important?
Props are a way of passing data from one React component to the other. Props are very important to make the components reusable.
5. How to manage global state?
In React the only way to access data in all components without any external package is Context API. Context works but it still has the problem of prop drilling so we usually use an external state management library to handle global state. The most popular one is Redux and there are some others as well like Recoil, Mobx, etc.
What questions you were asked in your React interviews?🤔 Let me down in the comments below 👇🏻
Useful links-