Learn React Js MCQs

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

How do you share state across components?

1) Using `context` or `props`

2) By using local state

3) Using `refs`

4) By creating a global variable

Answer : Option 1

What does `React.lazy` do?

1) It allows you to define a component that is loaded dynamically

2) It manages state

3) It handles side effects

4) It creates refs

Answer : Option 1

How do you create a custom hook?

1) By writing a function that uses React hooks

2) By using `useState`

3) By using `useEffect`

4) By using `useRef`

Answer : Option 1

What is the purpose of `useTransition`?

1) To mark updates as non-urgent

2) To handle state

3) To create refs

4) To manage side effects

Answer : Option 1

How do you define a functional component?

1) By creating a function that returns JSX

2) By using `class` keyword

3) By using `createRef`

4) By using `useEffect`

Answer : Option 1

What is the purpose of `useImperativeHandle`?

1) To customize the instance value that is exposed to parent components when using `ref`

2) To manage state

3) To create refs

4) To handle side effects

Answer : Option 1

How do you implement local state management?

1) Using `useState`

2) Using `useEffect`

3) Using `useRef`

4) Using `context`

Answer : Option 1

What is the purpose of `useDeferredValue`?

1) To defer the value update until the component has finished rendering

2) To manage state

3) To create refs

4) To handle side effects

Answer : Option 1

How do you perform cleanup in `useEffect`?

1) By returning a cleanup function

2) By using `useRef`

3) By using `useState`

4) By using `props`

Answer : Option 1

What is the primary benefit of using React?

1) Building user interfaces with reusable components

2) Managing backend data

3) Handling API calls

4) Optimizing server performance

Answer : Option 1