This might be caused by rendering your app in React.StrictMode
, it causes dual-renders in development mode. https://reactjs.org/docs/strict-mode.html. It also suppresses console
calls on subsequent renders, which may explain the difference you're seeing:
Starting with React 17, React automatically modifies the console methods
like console.log() to silence the logs in the second call to lifecycle functions. However, it may cause undesired behavior in certain cases where a workaround can be used.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…