Overview
Header is the main navigation component that appears at the top of every page. It provides branding (ReactFlix logo), main navigation links, and a user account section. The header uses React Router’s useLocation hook to highlight the active page.
Import
Props
This component takes no props.Features
Logo and Branding
The header displays the ReactFlix logo with a clickable link to the home page:src/components/Header.jsx
<span> for custom styling.
Navigation Menu
The header includes four main navigation links:src/components/Header.jsx
Active Link Highlighting
The component usesuseLocation() from React Router to detect the current page and applies the header__nav-link--active class to the matching navigation link:
src/components/Header.jsx
User Section
The header includes a user account section with an icon and username:src/components/Header.jsx
Usage
The Header component is rendered at the app level inApp.js so it appears on all pages:
src/App.js
Styling
The Header component uses BEM class naming:header- Main containerheader__container- Inner content wrapperheader__logo- Logo linkheader__nav- Navigation containerheader__nav-list- Unordered list of nav itemsheader__nav-item- Individual nav itemheader__nav-link- Nav link elementheader__nav-link--active- Active state modifierheader__user- User section containerheader__user-icon- User icon wrapperheader__user-name- Username text
src/styles/components.css.
Customization
Changing Navigation Links
To add or modify navigation links, edit the navigation list insrc/components/Header.jsx:17:
Updating the Logo
Modify the logo text or structure in the header logo section (src/components/Header.jsx:10).
Adding User Authentication
Replace the static user section with a dynamic component that shows the logged-in user’s name or a login button:Source Code
View the complete source code atsrc/components/Header.jsx:1.
Related Components
Footer
Application footer component
Routing Guide
Learn about navigation and routing