Bird
0
0

Identify the error in this Remix loader function that causes slow page loads: export async function loader() { const data = await fetch('/api/data').then(res => res.json()); return data; }

medium📝 Debug Q6 of 15
Remix - Performance
Identify the error in this Remix loader function that causes slow page loads: export async function loader() { const data = await fetch('/api/data').then(res => res.json()); return data; }
AUsing async/await inside the loader function
BFetching data from an API endpoint
CReturning raw data instead of using Remix's json() helper
DNot using useEffect to fetch data
Step-by-Step Solution
Solution:
  1. Step 1: Review Remix loader return requirements

    Remix expects loader functions to return a Response or use the json() helper to serialize data properly.
  2. Step 2: Identify impact of returning raw data

    Returning raw data can cause Remix to fail to send data efficiently, slowing page loads.
  3. Final Answer:

    Returning raw data instead of using Remix's json() helper -> Option C
  4. Quick Check:

    Use json() helper to return loader data [OK]
Quick Trick: Always return data with Remix's json() helper [OK]
Common Mistakes:
MISTAKES
  • Thinking async/await is wrong in loader
  • Believing fetching data is the error
  • Confusing loader with client useEffect

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Remix Quizzes