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

211
Visualizações
How to append to the div in babeljs

Using this always updates the html but doesn't append to it.

function App(props) {
  return (
    <div>
      hello
    </div>
  );
}

const root = ReactDOM.createRoot(document.getElementById("emails-view-content"));
for (let i = 0; i < 3; i++) {
  
  root.render(<App/>);
}

I want to write hello 3 times instaed of just one.

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

App should be the component that adds the "hello" statements to the HTML.

How you do that is entirely up to you but here's a simple example. It uses a separate <Hello> component. App receives a number in its props which it uses to create an array of <Hello> components which are then rendered.

function App({ number }) {

  function buildHellos(n) {
    return new Array(n).fill(<Hello />);
  }

  return (
    <div>{buildHellos(+number)}</div>
  );

}

function Hello() {
  return <p>Hello</p>;
}

ReactDOM.render(
  <App number="3" />,
  document.getElementById('react')
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.production.min.js"></script>
<div id="react"></div>

about 4 years ago · Santiago Trujillo 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