When going for a react js interview, you’ll get asked various questions but in this list, I am going to list out some common questions with answers that are asked in interviews and it might help you to crack your next interview.
What are the pros and cons of react js?
for this question, you can just list out a couple of bullet points and you don’t need to explain to them unless you are not asked to do so.
pros:
Cons:
Props in react js?
The answer to this question is quite simple “Props are arguments that are used to pass data in components.”
What is JSX?
The answer to this question is: “JSX is actually a syntax extension in Javascript which allows us to write javascript and HTML together.” A simple definition of jsx looks like this.
Difference between class components and functional components?
| Functional component | Class component |
|---|---|
| A functional component is also known as a stateless component that simply accepts data and represents them in some form to render the UI | A class component which a stateful component because it implements logic and state. |
What is useState?
useState() is a react hook that lets you manage the state in the functional component.
What is prop drilling in react?
Props drilling is basically “when you want to pass some data and you have to go through levels of components due to requirements in the final level and you keep passing on the props in the components is called prop drilling.”
What is the difference between map() and filter()
A filter() function will check the condition and return a brand new array whereas the map() will alter the existing array and returns the new altered array.
What is useEffect
useEffect is a react hook that works as the lifecycle method for functional components.
What is async/await?
An async function is a function declared with the async keyword, and the await keyword is permitted within it. The async and await keywords enable asynchronous, promise-based behavior to be written in a cleaner style, avoiding the need to explicitly configure promise chains.
What is the difference between async/await and promises?
A promise is an object representing an intermediate state of operation which is guaranteed to complete its execution at some point in the future. Async/Await is syntactic sugar for promises, a wrapper making the code execute more synchronously.