Build skeleton placeholders shown while content loads.
Skip to solutionKEEP THE
easyMachine Coding
Build a Skeleton Loader
477 views
01
Understand the problem
ReactLoadingUI
02
Attempt it yourself
Sketch your approach before reading the solution — that's what interviews test.
Nudge consolestandby
Stuck? Beam a request up — the console returns a conceptual nudge that guides your logic without spoiling the implementation.
03
Study the solution
Solve in
Building a Skeleton Loader in React
Mental model: A skeleton is a grey placeholder shaped like the content that's loading, with a moving shimmer to signal activity. Build one primitive <Skeleton> (width/height/radius props) and compose it into a card layout. Swap skeleton ↔ real content on a loading flag.
Solution ready — 2 min read
Classified // press E to declassify
04
React solution
Complete solutionRun Playground
import React, { useState, useEffect } from 'react';
import { Card, CardSkeleton } from './src/SkeletonLoader';
export default function App() {
const [loading, setLoading] = useState(true);
useEffect(() => {
const id = setTimeout(() => setLoading(false), 2000);
return () => clearTimeout(id);
}, [loading]);
return (
<div style={{ fontFamily: 'sans-serif', padding: 20 }}>
<h1>Skeleton Loader Demo</h1>
<button onClick={() => setLoading(true)} style={{ marginBottom: 16, padding: '6px 12px', cursor: 'pointer' }}>
Reload
</button>
{loading ? <CardSkeleton /> : <Card />}
</div>
);
}05
Join the discussion
Discussion (0)
Sign in to join the discussion.
No responses yet. Be the first to share what you think.
Transmission complete // awaiting log
KEEP THE
STREAK ALIVE.
Dossier 14 of 87 decoded in the Frontend Machine Coding track. One more won't hurt.