Programming Exercises

Build a component that displays a loading message for 3 seconds before showing the content.

Easy

Problem Statement

Build a component that displays a loading message for 3 seconds before showing the content.

Sample Output

Initially: Loading...
 After 3 seconds: Content loaded!

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
import React, { useState, useEffect } from "react"; const Loader = () => { const [isLoading, setIsLoading] = useState(true); useEffect(() => { // Set a timeout to change loading state }, []); return <div>{isLoading ? "Loading..." : "Content loaded!"}</div>; }; export default Loader;
Log in or sign up to run or submit your code.Log inSign up
Expected Output
Initially: Loading...
 After 3 seconds: Content loaded!