Clima React App is a single-page weather lookup application built with Create React App. The application follows a straightforward top-down architecture: one root component (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/jantoniogc/CursoReact-Clima/llms.txt
Use this file to discover all available pages before exploring further.
App) owns all shared state and coordinates every side effect, while four focused leaf components handle specific pieces of the UI. Styling is provided by Materialize CSS, and weather data is fetched from the OpenWeatherMap REST API directly inside App.
Component hierarchy
App is the only stateful component. It renders Header unconditionally at the top, then places Formulario and either Clima or Error side-by-side in a two-column Materialize grid.
Data flow
- User input —
Formulariomaintains a controlled form backed by thebusquedaobject passed down fromApp. Every keystroke callssetBusqueda(also fromApp), which lifts the updated{ciudad, pais}value back up toApp’s state. - Submit trigger — When the user submits the form and validation passes,
FormulariocallssetConsultar(true), flipping the boolean trigger flag inApp. - API call —
App’suseEffectwatchesconsultar. When it becomestrue, the effect fires an async fetch to the OpenWeatherMap API using the currentciudadandpaisvalues. After the response arrives, it stores the raw JSON inresultado, setserrorbased on whether the API returnedcod: '404', and resetsconsultartofalse. - Results display —
Apppassesresultadodown toClima, which readsnameandmainfrom the response to render temperatures. Iferroristrue,Apprenders<Error>instead of<Clima>.
Why App owns all state
App coordinates three distinct concerns that would otherwise need to communicate across siblings:
- Form state (
busqueda) — needs to be readable by the API call logic, not just byFormulario. - API call trigger (
consultar) — set byFormulariobut consumed byApp’suseEffect. - Results and error state (
resultado,error) — produced by the API call and consumed byClima/Error.
App avoids prop-drilling between siblings and keeps each leaf component focused on a single presentational responsibility.
Materialize CSS is loaded from a CDN link in
public/index.html, not installed as an npm dependency. This means Materialize utility classes (such as nav-wrapper, card-panel, input-field, and red darken-4) are available globally at runtime but are not tree-shaken or bundled by webpack.