Challenge - 5 Problems
Client-side Routing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
What happens when you click a in React Router?
Consider a React app using React Router. When you click a component, what is the main behavior that happens?
React
<Link to="/about">About</Link>Attempts:
2 left
💡 Hint
Think about how single-page apps avoid full page reloads.
✗ Incorrect
React Router's prevents the browser's default full page reload. Instead, it changes the URL and renders the new component inside the app, making navigation fast and smooth.
📝 Syntax
intermediate2:00remaining
Identify the correct way to define a route in React Router v6
Which of the following is the correct syntax to define a route that renders at path '/'?
Attempts:
2 left
💡 Hint
React Router v6 uses a new prop to specify what to render.
✗ Incorrect
In React Router v6, the element prop is used to specify the component to render. The other props were used in older versions.
❓ state_output
advanced2:00remaining
What is the URL and rendered output after navigating programmatically?
Given this React Router code snippet, what will be the URL and rendered output after the button is clicked?
React
import { useNavigate, Routes, Route } from 'react-router-dom'; function App() { const navigate = useNavigate(); return ( <> <button onClick={() => navigate('/dashboard')}>Go Dashboard</button> <Routes> <Route path="/" element={<h1>Home</h1>} /> <Route path="/dashboard" element={<h1>Dashboard</h1>} /> </Routes> </> ); }
Attempts:
2 left
💡 Hint
useNavigate changes the URL and triggers route rendering.
✗ Incorrect
The navigate('/dashboard') call changes the URL to '/dashboard' and React Router renders the matching route's element, which is <h1>Dashboard</h1>.
🔧 Debug
advanced2:00remaining
Why does the route not render the component on URL change?
A developer wrote this React Router setup but the component does not render when the URL changes. What is the likely cause?
React
import { BrowserRouter, Routes, Route } from 'react-router-dom'; function App() { return ( <BrowserRouter> <Route path="/about" element={<About />} /> </BrowserRouter> ); }
Attempts:
2 left
💡 Hint
Check the required parent components for Route in React Router v6.
✗ Incorrect
In React Router v6, Route components must be wrapped inside a Routes component. Without Routes, the route will not render.
🧠 Conceptual
expert3:00remaining
Why use client-side routing instead of server-side routing in React apps?
Which of the following best explains the main advantage of client-side routing in React apps?
Attempts:
2 left
💡 Hint
Think about user experience and speed when clicking links in single-page apps.
✗ Incorrect
Client-side routing updates the URL and page content without reloading the whole page, which makes the app feel faster and more responsive.