/coins/markets endpoint and renders them in a responsive table. Data is cached in localStorage for 5 minutes via keepInfo() to avoid unnecessary API calls on every page visit.
Data loading
TheHome page component calls keepInfo() inside a useEffect on mount:
home.jsx
keepInfo() checks localStorage first. If a valid cache entry exists (less than 5 minutes old) it returns the cached result; otherwise it calls getTopCryptos(), which hits:
Table columns
The desktop table renders the following columns in order:| Column | Description |
|---|---|
# (logo) | Coin logo image sourced from CoinGecko |
| Name | Full coin name (e.g. Bitcoin) |
| Sym | Ticker symbol, displayed uppercased (e.g. BTC) |
| Price | Current price in USD |
| Volume | 24-hour total trading volume in USD |
| Market Cap | Market capitalization in USD |
| Change 24h | Price change percentage over the last 24 hours, colored green (positive) or red (negative) |
| Favoritos | Star icon button — click to toggle the coin as a favorite |
CryptoCard component
Each row in the list is rendered by theCryptoCard component. It accepts the following props:
Unique CoinGecko coin identifier (e.g.
"bitcoin", "ethereum"). Used as the key and as the favorites identifier.Ticker symbol (e.g.
"btc"). Displayed uppercased in the symbol column.URL of the coin logo image sourced from CoinGecko.
Human-readable coin name (e.g.
"Bitcoin").Market capitalization in USD. Formatted with
formatter from formatNumbers.js.24-hour trading volume in USD. Formatted with
formatter from formatNumbers.js.Current price in USD. Formatted with
formatter from formatNumbers.js.Price change percentage over the last 24 hours. Displayed in green when positive, red when negative.
Currency formatting
All monetary values are formatted using theformatter instance exported from src/utils/formatNumbers.js:
formatNumbers.js
$45,231.00 and $1,234,567,890.00 consistently across all columns.
Responsive layout
The listing uses a two-layout approach controlled by Tailwind CSS breakpoints:- Mobile (< md)
- Desktop (>= md)
Each coin is rendered as a card with the logo, name, and symbol at the top, followed by a two-column grid showing price, volume, market cap, and 24h change. The favorite toggle appears in the top-right corner of the card.
The header row (
#, Name, Sym, Price, …) is only visible on md and larger screens. The mobile card view shows the same data in a stacked grid layout.