React Advanced

0% completed

Previous
Next
Code Challenge

Challenge: Practice Lazy Loading a Component

Follow the instructions below to complete the challenge:

  1. Create a Heavy Component: Implement a HeavyComponent that displays a large amount of text or images.

  2. Use React.lazy for Lazy Loading: Instead of importing HeavyComponent directly, use React.lazy() to load it dynamically.

  3. Wrap it with Suspense: Use <Suspense> with a fallback (e.g., "Loading...") to show a placeholder while the component loads.

  4. Add a Button to Load the Component: Render the HeavyComponent only when a user clicks a "Load Component" button.

.....

.....

.....

Like the course? Get enrolled and start learning!
Previous
Next