为什么 App 或 Quiz 组件呈现两次?

Why App or Quiz component rendered two times?

当我在 App 组件或 Quiz 组件中记录任何字符串时,它在控制台中出现两次。

这是因为您使用的是StrictMode,会造成多次渲染。 This in intentionally 已完成以帮助鼓励开发人员正确使用副作用。双重渲染只会发生在开发中,不会发生在生产中。

另请参阅此 answer 了解更多信息。

严格模式开启,因为您的组件用 <React.StrictMode>:

包裹
<React.StrictMode>
    <Router>
        ...
        ...
</React.StrictMode>