为什么 console.log 在反应中运行两次

Why console.log in react runs twice

每次我 运行 我在 reactjs 上的代码,console.log() 运行 在构造函数、渲染器或组件中两次。为什么要这样做?

class App extends Component {
  constructor(props){
    super(props);
    console.log("[App.js] constructor")
  }

您可能在严格模式下使用 React。因此它出现了两次。当您使用 React 应用程序的生产版本时,不会发生这种情况。
This might help you further