Everytime I run my code on reactjs, console.log() runs twice in constructor,render, or in the components. Why does it do that?
class App extends Component {
constructor(props){
super(props);
console.log("[App.js] constructor")
}
Everytime I run my code on reactjs, console.log() runs twice in constructor,render, or in the components. Why does it do that?
class App extends Component {
constructor(props){
super(props);
console.log("[App.js] constructor")
}
You are probably using React in Strict Mode. Hence it occurs twice. This wont happen when you use production build of your react app.
This might help you further