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

242
Visualizações
Prettier adding semicolon when semi: false

I have a react component with this jsx

  {posts?.map((post) => {
    <Post key={post.id} post={post} />
  })}

When I save the file prettier automatically adds a semicolon infront of <Post ... />. This is causing the component to fail to render.

I have the semi option set to false.

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

0

This is happening because currently your map function is not returning anything

<Post key={post.id} post={post} /> needs to be returned by map just like you return jsx inside your react component.

If you want to keep the one line and not explicitly return, change your curly braces to parenthesis to return your jsx

 {posts?.map((post) => (
    <Post key={post.id} post={post} />
  ))}

which is the same as

{posts?.map((post) => {
      return <Post key={post.id} post={post} />;
    })}
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