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

115
Visualizações
React - Render more than one Component

I have the typical index.js that calls App.js

index.js

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';

ReactDOM.render(
  
    <App />,
  
  document.getElementById('root')
);

App.js

import './App.css';
import Test from './Components/test'
import Test1 from './Components/test1'

function App() {
  return (
<Test/>,
<Test1/>
    );
}

export default App;

When building App.js i wanted to render 2 components Test and Test1

When i run this code only one of the components gets rendered. In this case only Test1 is rendered. If i switch the order only Test is rendered

Is there any way that i can render 2 components?

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

0

You can only render one component, so an approach would be to wrap them in one. For example, in a React Fragment, like so:

import { Fragment } from 'react'

...

return (
  <Fragment>
    <Test />
    <Test1 />
  </Fragment>
)

Fragment is just a wrapper, it doesn't provide any functionality. Alternatively, you can wrap your components like so:

return (
  <>
    <Test />
    <Test1 />
  </>
)

The result would be the same.

about 4 years ago · Juan Pablo Isaza Relatório

0

You need to wrap this Test and Test1 into some wrap

import './App.css';
import Test from './Components/test'
import Test1 from './Components/test1'

function App() {
  return (
  <div>
    <Test/>,
    <Test1/>
  </div>
    );
}

export default App;

about 4 years ago · Juan Pablo Isaza Relatório

0

try this

function App() {
  return (
    <>
      <Test />
      <Test1 />
    </>
  )
}
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