← Quiz: React Basics: all 10 questions
Quiz: React Basics · Question 10 of 10
Why should data fetching go inside useEffect instead of directly in the component body?
Why should data fetching go inside useEffect instead of directly in the component body?
- A.fetch does not work outside useEffect
- B.The component body runs on every render, so fetching there would repeat the request again and again
- C.useEffect makes requests faster
- D.Components cannot use await
Answer & explanation
Correct answer: The component body runs on every render, so fetching there would repeat the request again and again
useEffect runs after rendering, controlled by its dependency array.
Can you get the rest right without peeking?
Take the timed Quiz: React Basics quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →