App component is the main entry point of the Been application. It manages the application’s layout, handles data loading, and coordinates communication between the Globe and Menu components.
Overview
The App component:- Loads country data asynchronously
- Manages loading and error states
- Provides a responsive grid layout
- Handles menu fullscreen toggle on mobile devices
Component Structure
State Management
The component manages several pieces of local state:loading- Boolean indicating if country data is being loadederror- Error object if data loading failsmenuFullscreen- Boolean controlling menu expansion on mobile
Layout Structure
The App uses a responsive grid layout that adapts to different screen sizes:Desktop Layout (md and up)
- 3-column grid
- Header spans 1 column
- Menu takes 1 column (full height)
- Globe takes 2 columns (full height)
Mobile Layout
- Single column with 3 rows
- Header at top
- Globe in middle (60vh minimum)
- Menu at bottom (expandable)
Usage Example
Data Loading
The component loads country data on mount:Error Handling
When an error occurs during data loading, a user-friendly error message is displayed with a retry button:Mobile Features
On mobile devices, the menu can be toggled to fullscreen mode using thetoggleMenuFullscreen callback, which is passed to the Menu component.
Dependencies
jotai- State managementclassnames- Conditional CSS classesreact- Core React functionality
Source Code
Location:src/components/app.tsx