I have a problem with this code. when compiling it shows me twice the message in the console ... it happens with any code that I put, also when I call a method. it is as if the component was run twice when it is class. when it is a function it does not happen, depending on if it is executed only once ... It is not that the message of "Hello world" appears twice, only one appears. but it is as if the component is updated or reloaded when it is class and I get the message in console twice. I am new to react and I would like you to help me with this question please.
import React, { Component } from 'react'
class Page extends Component {
getMessage(){
console.log("hello1")
}
render(){console.log("hello2")
return (
<div>
<h2>Hello world</h2>
{this.getMessage()}
</div>
)
}
}
export default Page;