Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!