Skip to main content
Frontend
Interviews
.dev
Problems
709. React useEffect Missing Dependency
Medium
•
...
Select the best answer.
React
.
useEffect
(
(
)
=>
{
fetch
(
'/api?q='
+
query
)
;
}
,
[
]
)
;
What is the main issue?
useEffect can use a stale query because the dependency is missing
Using fetch inside useEffect is invalid React usage
The query value must be stored in a ref first
Fetch requires a callback wrapper to run in effects
Submit Answer
Reveal Answer
Select an option and submit your answer.
Next Problem
Auto-advance on correct answer