React Fundamentals

0% completed

Previous
Next
Quiz
Question 1
Which of the following are true about the useState hook in React?
Choose all correct options
It automatically shares state between multiple components.
It allows functional components to manage local state.
It can only be used inside class components.
The updater function can be used to modify the state value.
Question 2
What is the primary difference between local state and global state in React applications?
A
Local state is specific to a single component, while global state is shared across multiple components.
B
Local state is initialized in the root component, while global state is initialized in child components.
C
Local state can only store strings, while global state can store any data type.
D
Local state requires external libraries for management, while global state does not.
Question 3
Which of the following is the correct way to initialize a state variable using useState?
A
const [count] = useState(0);
B
const count = useState(0);
C
const [count, setCount] = useState(0);
D
useState(count, setCount, 0);
Question 4
If you need to update a state variable based on its previous value, how should you do it?
A
setCount(count + 1);
B
setCount(count++);
C
setCount({ count: count + 1 });
D
setCount(prevCount => prevCount + 1);

.....

.....

.....

Like the course? Get enrolled and start learning!
Previous
Next