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

363
Visualizações
Difference between <React.Fragment> vs <>

I wanted to know the difference between <React.Fragment> versus <> in terms of the efficiency?

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

0

I think it is mostly same, with main difference:

You can use <></> the same way you’d use any other element except that it doesn’t support keys or attributes.

More.


About efficiency, IMHO there should be no difference, at least it is not documented.

Here is brief experiment, using Test1 or Test2 inside Main gives same performance more or less, if you check using React Profiler:

let array = [...new Array(1000)];

let Test1 = (props) => {
  return (
    <>
      <div>a</div>
      <div>b</div>
      <div>b</div>
    </>
  );
};

let Test2 = (props) => {
  return (
    <React.Fragment>
      <div>a</div>
      <div>b</div>
      <div>b</div>
    </React.Fragment>
  );
};

let Main = (props) => {
  return (
    <div>
      {array.map((x) => (
        <Test2 />
      ))}
    </div>
  );
};

export default function App() {
  return (
    <div>
      <Main />
    </div>
  );
}
about 4 years ago · Juan Pablo Isaza Relatório

0

It is the same thing. The <> is just a short syntax.

about 4 years ago · Juan Pablo Isaza Relatório

0

The <></> syntax is shorthand of <React.Fragmet> with a little difference. you Can't pass key or attributes to <>

someArray.map(item => (
        // Without the `key`, React will fire a key warning
        <React.Fragment key={item.id}>
          <dt>{item.term}</dt>
          <dd>{item.description}</dd>
        </React.Fragment>
      ))

The above example is not possible with <>

Check react docs for more info

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