Learn React Js MCQs

Prepare React Js MCQs (Multiple choice Questions) for exam and job interviews.

How do you prevent re-renders in a React component?

1) Using `useState`

2) Using `React.memo`

3) Using `useEffect`

4) Using `useReducer`

Answer : Option 2

What is the purpose of `useEffect`?

1) To manage state

2) To handle side effects in a component

3) To create refs

4) To optimize performance

Answer : Option 2

How do you optimize performance in a React application?

1) Using `useState`

2) Using `useMemo` and `React.memo`

3) Using `useEffect`

4) Using `useReducer`

Answer : Option 2

What is the purpose of `React.Portal`?

1) To manage state

2) To render children into a DOM node that exists outside the DOM hierarchy of the parent component

3) To create refs

4) To handle side effects

Answer : Option 2

How do you create higher-order components in React?

1) By wrapping a component with another function

2) Using `useState`

3) Using `useEffect`

4) Using `React.forwardRef`

Answer : Option 1

What is the purpose of `React.Suspense`?

1) To manage state

2) To handle asynchronous rendering of components

3) To create refs

4) To handle side effects

Answer : Option 2

How do you handle complex state logic in React?

1) Using `useState`

2) Using `useEffect`

3) Using `useReducer`

4) Using `useRef`

Answer : Option 3

What is the purpose of `useCallback` in React?

1) To manage state

2) To handle side effects

3) To memoize a callback function

4) To create refs

Answer : Option 3

How do you handle user authentication in a React app?

1) Using `useState`

2) Using `useContext` and `context` API

3) Using `useEffect`

4) Using `useRef`

Answer : Option 2

What is the purpose of the `useReducer` hook?

1) To manage state that depends on previous state

2) To create refs

3) To handle side effects

4) To optimize performance

Answer : Option 1