Loading

Quipoin Menu

Learn • Practice • Grow

react / useState Hook in React
mcq
Direction: Choose the correct option

Q1.

What does the useState hook return?
A. The current state value only
B. A single value
C. An object with state and setter
D. An array with the current state and a function to update it
Direction: Choose the correct option

Q2.

How do you import useState?
A. import { useState } from 'react-dom';
B. import useState from 'react';
C. import React, { useState } from 'react';
D. import React.useState from 'react';
Direction: Choose the correct option

Q3.

What is the initial value passed to useState used for?
A. It sets the type of state
B. It sets the state on every render
C. It is ignored
D. It sets the state only once when the component mounts
Direction: Choose the correct option

Q4.

Which of the following correctly declares a state variable 'count' with setter 'setCount'?
A. const [count, setCount] = useState(0);
B. const [count, setCount] = React.useState(0);
C. const [count, setCount] = useState;
D. const count = useState(0);
Direction: Choose the correct option

Q5.

If you call the setter function (e.g., setCount) with the same value as current state, what happens?
A. An error is thrown
B. React may skip re-rendering if it detects no change
C. React always re-renders
D. The component unmounts