Bird
0
0

What is wrong with this Remix lazy loading code snippet?

medium📝 Debug Q14 of 15
Remix - Performance
What is wrong with this Remix lazy loading code snippet?
const LazyComp = React.lazy(import('./LazyComp'));

export default function App() {
  return ;
}
ABoth B and C are errors.
BLazyComp must be wrapped in Suspense with fallback UI.
CReact.lazy requires a function returning import, not import called directly.
DThere is no error; this code works fine.
Step-by-Step Solution
Solution:
  1. Step 1: Check React.lazy usage

    React.lazy expects a function returning import(), but here import() is called immediately.
  2. Step 2: Check Suspense usage

    Lazy loaded components must be inside Suspense with a fallback UI to handle loading state.
  3. Final Answer:

    Both B and C are errors. -> Option A
  4. Quick Check:

    React.lazy needs function + Suspense fallback [OK]
Quick Trick: React.lazy needs a function and Suspense fallback [OK]
Common Mistakes:
MISTAKES
  • Calling import() directly inside React.lazy
  • Not wrapping lazy component in Suspense
  • Assuming lazy loading works without fallback

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Remix Quizzes