如何在第三方库上禁用反应严格模式

bab*_*ego 9 strict-mode reactjs

我们在 React 应用程序中使用严格模式。但是第三方不使用严格模式。我怎样才能做到这一点?谢谢

小智 1

index.js文件中删除React.StrictMode包装。

由此

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
  <React.StrictMode>
     <App />
  </React.StrictMode>
);
Run Code Online (Sandbox Code Playgroud)

对此

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);
Run Code Online (Sandbox Code Playgroud)

  • 这是一个老问题,所以我怀疑我们是否会从提问者那里得到澄清,但我认为他们只是试图禁用第三方组件的严格模式,而不是他们的整个应用程序。 (6认同)