Learn React Js MCQs

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

How do you manage complex state logic?

1) Using `useState`

2) Using `useEffect`

3) Using `useReducer`

4) Using `useRef`

Answer : Option 3

What is the purpose of `useCallback`?

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?

1) Using `useState`

2) Using `useContext` and `context` API

3) Using `useEffect`

4) Using `useRef`

Answer : Option 2

What is the purpose of `useReducer`?

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

How do you pass data between siblings?

1) Using `props`

2) Using `context`

3) Using a parent component

4) Using `useState`

Answer : Option 3

What is the purpose of `React.StrictMode`?

1) To manage state

2) To optimize performance

3) To identify potential problems in the application

4) To handle side effects

Answer : Option 3

How do you handle conditional rendering?

1) Using `useState`

2) Using `useEffect`

3) Using `if-else` or ternary operators

4) Using `useContext`

Answer : Option 3

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?

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