Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

122
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda