Learn React Js MCQs

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

What is the purpose of React.createContext?

1) To create a context for state management

2) To create a new component

3) To manage component lifecycle

4) To handle props

Answer : Option 1

How do you handle side effects in React functional components?

1) Using useEffect hook

2) Using useState hook

3) Using useMemo hook

4) Using useCallback hook

Answer : Option 1

What does useEffect hook do?

1) Handles side effects in function components

2) Creates a class component

3) Manages component state

4) Sets default props

Answer : Option 1

How do you access a ref in a React component?

1) Using ref.current property

2) Using ref.get() method

3) Using ref function

4) Using ref.value property

Answer : Option 1

What is the purpose of React.forwardRef?

1) To forward refs to child components

2) To manage component state

3) To handle events

4) To create context

Answer : Option 1

How do you handle multiple state variables in a React component?

1) Using useState hook multiple times

2) Using a single state object with useState

3) Using useEffect hook

4) Using useMemo hook

Answer : Option 2

What is the purpose of React.lazy?

1) To enable lazy loading of components

2) To create class components

3) To handle state

4) To perform side effects

Answer : Option 1

How do you create a custom hook in React?

1) By creating a function that uses other hooks

2) By using useCustomHook method

3) By extending React.Component

4) By using React.createClass

Answer : Option 1

What is the purpose of React.PureComponent?

1) To create components with shallow comparison of props and state

2) To manage component state

3) To handle events

4) To create higher-order components

Answer : Option 1

How do you access route parameters in React Router?

1) Using props.match.params

2) Using useHistory hook

3) Using useLocation hook

4) Using useParams hook

Answer : Option 4