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

156
Visualizações
Why React renders my component a second time?

I have the following ReactJS code:

import React, { useState } from 'react';
import { render } from 'react-dom';

export default function App() {
    console.log('Render');

    const [isOpen, setIsOpen] = useState(false);

    const handleOpen = () => {
        setIsOpen(true);
    }

    return (
        <div>
            <button onClick={handleOpen}>Click</button>
        </div>
    );
}

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

When the app loads in the browser "Render" is outputted in the console. Then, when I click on the button, "Render" is outputted another time, and it makes sense because the state changes.

However, another click on the button, outputs "Render" again in the console :/ And after that when clicking on the button, no more outputs.

Can someone help me understand why this component is rendered on the second button click?

Thanks

about 4 years ago · Juan Pablo Isaza
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