🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.fetch does not work outside useEffect
  2. B.The component body runs on every render, so fetching there would repeat the request again and again
  3. C.useEffect makes requests faster
  4. 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 →