Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
React router v6

Hello when I try to get data from a file. The react app goes blank. Here is what I have:

import React from 'react';
import {Link, useParams} from "react-router-dom";
import articles from "./article-content";

const ArticlePage = () =>{
const { name } = useParams();
const { article } = articles.find(article => article.name === name)

return(
<>
    <div id="page-body">
        <h1>{article.title}</h1>
        <h1>{article.content}</h1>
    </div>
</>
);
}
export default ArticlePage;

and here is example of the article-content:

const articles = [
{
    name: 'learn-react',
    title: 'The Fastest Way to Learn React',
    content: [.....
]]
export default articles;

Any ideas why it's going blank instead of rendering?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can use the Chrome's console to have a clue of what is happening with your app. Press F12 or right click on your Chrome and open the Inspector, and then go to the "Console" tab. It will be your best tool for debugging your apps.

about 4 years ago · Juan Pablo Isaza Report

0

Please change the below lines from const { name } = useParams(); const { article } = articles.find(article => article.name === name)

to const name = useParams(); const article = articles.find(article => article.name === name)

you cannot able to destructure it.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!