Data loading
News is fetched viakeepNews() from cache.js when the News page mounts:
news.jsx
keepNews() calls the CryptoCompare news endpoint:
Results are cached in
localStorage under the key getNewsCrypto for 5 minutes. Navigating away and back to the news page within that window will render from cache without an additional network request.CryptoNewsCard component
Each article is rendered byCryptoNewsCard in src/components/cryptoNews.jsx. The component accepts the following props:
Article headline. Displayed clamped to 2 lines.
Article body text. Displayed clamped to 3 lines.
Publication source name (e.g.
"CoinDesk"). Falls back to "Fuente desconocida" when absent.URL of the article cover image. Falls back to an Unsplash crypto image when absent.
ISO 8601 date string. Formatted for display using
es-ES locale (dd MMM yyyy).Link to the full article. Opens in a new tab.
Page states
TheNews page handles four conditional UI states driven by loading, error, and news.length:
| Condition | UI shown |
|---|---|
loading === true | Text message: "Cargando noticias..." in a bordered card |
!loading && error | Red bordered card with message: "No se pudieron cargar las noticias. Inténtalo de nuevo." |
!loading && !error && news.length > 0 | Grid of CryptoNewsCard article cards |
!loading && !error && news.length === 0 | Neutral card: "No hay noticias disponibles ahora mismo." |