There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
You can also find further discussion and get answers to your questions over in Language Help.
Agree with a comment or answer? Like () to up-vote the contribution!
I recently started coding, so sorry if my response is a bit late, you don’t need the “exact” keyword for the path. I just found out that for the previous step when you import the {Link} from react-router-dom" you need to make you compile (Crtl + S) the “Article.js” component. That fixed it for me anyway
Issue: React Router Not Rerouting Properly to Dynamic Article Pages
Problem
In a React application, clicking on links within Articles.js was not routing to the dynamic Article.js component properly. The links were created using <a> tags, which caused a full page reload instead of using React Router’s dynamic routing.
Solution
To enable React Router to handle the routing without reloading the page:
Replace <a> Tags with React Router’s <Link> Component:
Import Link from react-router-dom in Articles.js.
Replace <a> tags with <Link to={...}> to leverage React Router’s routing capabilities.
Update Articles.js Component:
Use <Link> to dynamically construct the route based on each article’s unique slug or identifier:
import { Link } from "react-router-dom";
// ...
<Link to={`/articles/${article.slug}`}>
{article.title}
</Link>
Ensure Dynamic Route is Set Up in App.js:
Confirm the route for articles/:title is defined in your main router configuration:
Confirm Article.js Uses useParams() to Retrieve Dynamic Data:
In Article.js, retrieve the title parameter from the URL using useParams() to display the appropriate article content.
Result
With these changes, clicking on an article link in Articles.js will correctly route to Article.js using the articles/:title route, allowing React Router to render the content dynamically without reloading the page.