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

175
Visualizações
React module logs perfectly on console, but does not show on the page

I am having a strange problem with the code below.

After mapping the notes, {notes.map(note => { ...}); console.log({notes}) returns an array of four items. There are four items in the array. Similarly, console.log({note.title}) logs each item's title as a map method would. When we call {note.title} on the line before console.log({note.title}), nothing appears on the page!!! An example of the code is shown below in a summarized form. The code with the problem has been pushed to the GitHub. You can see it under the commit "MyNotes.js not rendering the data on-screen while it logs them perfectly on the console".

The dev-tool console logs this error

Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check your code at MyNotes.js:31.

https://github.com/bdarab/notezipper-mern

{
  notes.map((note) => {
    <Card style={{ margin: 10 }}>
      <Card.Header style={{ display: 'flex' }}>
        <span
          style={{
            alignSelf: 'center',
            color: 'black',
            cursor: 'pointer',
            flex: 1,
            fontSize: 18,
            textDecoration: 'none',
          }}
        >
          {note.title} // Doesn’t work console.log(note); // Works perfectly
        </span>

        <div>
          <Button>Edit</Button>

          <Button className='mx-2' variant='danger'>
            {' '}
            Delete{' '}
          </Button>
        </div>
      </Card.Header>
    </Card>;
  });
}

The strange thing is that everything works when I console.log() them, but it doesn't appear on the page. I continued coding blindly. Now, I have methods of showing {note._id}, {note.category}, and {note.content}that work perfectly when I log them on the console. In real code, though, I get no results. Why? https://github.com/bdarab/notezipper-mern

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

0

add a return statement.

return <Card style={{ margin: 10 }}>

about 4 years ago · Juan Pablo Isaza Relatório

0

Thanks, everyone! Problem solved. it was a react-bootstrap problem. Using codes of 1.6 version while npm had installed the newer 2.0 version. thanks for your interest.

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