Coding task · JavaScript and React course · Module 6: React Router
Practice: Route Configuration
NavLink automatically adds an 'active' class when the path matches. Use: className={({ isActive }) => isActive ? 'nav-active' : ''}. Perfect for highlighting the current section in the navigation panel!
Task
Create navigation: <nav><NavLink to='/' className={({isActive}) => isActive ? 'active' : ''}>Home</NavLink><NavLink to='/asteroids'>Asteroids</NavLink></nav>. Add CSS: .active { color: gold; border-bottom: 2px solid gold }