Enable React strict mode

This enables React strict mode which will print extra warnings to the
console when we use certain constructs incorrectly. This does not affect
production builds.

See https://beta.reactjs.org/reference/react/StrictMode
This commit is contained in:
Koen Vlaswinkel
2023-03-13 16:41:26 +01:00
parent e949b96057
commit 9b1dee6314

View File

@@ -1,4 +1,5 @@
import * as React from "react";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { vscode } from "./vscode-api";
@@ -27,10 +28,12 @@ const render = () => {
const view: WebviewDefinition = require(`./${viewName}/index.tsx`).default;
createRoot(element).render(
// Post a message to the extension when fully loaded. See https://github.com/reactwg/react-18/discussions/5 ("What about the render callback?")
<div ref={() => vscode.postMessage({ t: "viewLoaded", viewName })}>
{view.component}
</div>,
<StrictMode>
{/* Post a message to the extension when fully loaded. See https://github.com/reactwg/react-18/discussions/5 ("What about the render callback?")*/}
<div ref={() => vscode.postMessage({ t: "viewLoaded", viewName })}>
{view.component}
</div>
</StrictMode>,
);
};