App component is the root component that initializes the application, manages Redux state, and configures React Router.
Component Structure
app.js
State Management
The component uses local state (data) to track Redux store initialization:
- Connects to Redux using
useSelectorto access thecamarasstate - On mount, copies
camarasto local state viauseEffect - Conditionally renders based on whether data exists
Conditional Rendering
- Data exists: Renders full application with
HashRouterand routes - Data is null: Displays
<OnLoad />loading spinner
Router Configuration
UsesHashRouter for client-side routing compatible with static hosting:
| Route | Component | Description |
|---|---|---|
/ | Principal | Landing page |
/productos | Main | Product catalog |
/nosotros | Nosotros | About us page |
/contacto | Contacto | Contact page |
/productos/camaras/:modelo | ViewCamera | Camera detail view |
/productos/camaras/filtro/:filter | FilterCamara | Filtered results |
* | NotFound | 404 error page |
Root Rendering
The app is wrapped with Redux Provider and rendered to the DOM:app.js
Dependencies
- React 18: Core framework with hooks (useState, useEffect)
- React Redux: State management integration
- React Router DOM 6.18: Client-side routing with HashRouter
Related
- Architecture - Application structure overview
- Routing - Detailed routing documentation
- State Management - Redux store configuration
- OnLoad - Loading component