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

303
Visualizações
React project displaying blank page on GitHub Pages

I have a project that is displaying a blank page on GitHub Pages. I have added

"homepage": "https://jusmccar.github.io/ContactManager",
"predeploy": "npm run build",
"deploy": "gh-pages -d build",

to my package.json and ran the commands

npm install gh-pages --save-dev
npm run deploy

Here is the link to my repo: ContactManager

I have another project FitClub that it works just fine on so I don't know what I'm doing wrong.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Your problem is here in App.js

const [contacts, setContacts] = useState(
  JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY))
);

You're not doing anything to handle the initial case where there is nothing in local storage.

This causes null to be passed to the contacts prop in ContactList. The code there attempts to use props.contacts.map() which leads to this error you see in your browser console...

Cannot read properties of null (reading 'map')
at x (ContactList.js:9:46)

I would suggest defaulting to an empty array when getItem() returns null

const [contacts, setContacts] = useState(
  JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY)) ?? []
);

A further suggestion would be to use TypeScript which would warn you about the potential for localStorage to return null values.

about 4 years ago · Juan Pablo Isaza Relatório

0

I think it deployed fine, but there is an error in your ContactsList component. Look it the console. TypeError: e.contacts is null

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