Skip to content

chore(site): enable React's StrictMode #13399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions site/.storybook/preview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
import { ThemeProvider as EmotionThemeProvider } from "@emotion/react";
import { DecoratorHelpers } from "@storybook/addon-themes";
import { withRouter } from "storybook-addon-remix-react-router";
import { StrictMode } from "react";
import { QueryClient, QueryClientProvider } from "react-query";
import { HelmetProvider } from "react-helmet-async";
import themes from "theme";
Expand All @@ -29,14 +30,16 @@ export const decorators = [
const selected = themeOverride || selectedTheme || "dark";

return (
<StyledEngineProvider injectFirst>
<MuiThemeProvider theme={themes[selected]}>
<EmotionThemeProvider theme={themes[selected]}>
<CssBaseline />
<Story />
</EmotionThemeProvider>
</MuiThemeProvider>
</StyledEngineProvider>
<StrictMode>
<StyledEngineProvider injectFirst>
<MuiThemeProvider theme={themes[selected]}>
<EmotionThemeProvider theme={themes[selected]}>
<CssBaseline />
<Story />
</EmotionThemeProvider>
</MuiThemeProvider>
</StyledEngineProvider>
</StrictMode>
);
},
];
Expand Down
20 changes: 14 additions & 6 deletions site/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import "./theme/globalFonts";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import { type FC, type ReactNode, useEffect, useState } from "react";
import {
type FC,
type ReactNode,
StrictMode,
useEffect,
useState,
} from "react";
import { HelmetProvider } from "react-helmet-async";
import { QueryClient, QueryClientProvider } from "react-query";
import { RouterProvider } from "react-router-dom";
Expand Down Expand Up @@ -74,10 +80,12 @@ export const AppProviders: FC<AppProvidersProps> = ({

export const App: FC = () => {
return (
<ErrorBoundary>
<AppProviders>
<RouterProvider router={router} />
</AppProviders>
</ErrorBoundary>
<StrictMode>
<ErrorBoundary>
<AppProviders>
<RouterProvider router={router} />
</AppProviders>
</ErrorBoundary>
</StrictMode>
);
};
20 changes: 7 additions & 13 deletions site/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
import { createRoot } from "react-dom/client";
import { App } from "./App";

// This is the entry point for the app - where everything start.
// In the future, we'll likely bring in more bootstrapping logic -
// like: https://github.com/coder/m/blob/50898bd4803df7639bd181e484c74ac5d84da474/product/coder/site/pages/_app.tsx#L32
const main = () => {
console.info(` ▄█▀ ▀█▄
console.info(` ▄█▀ ▀█▄
▄▄ ▀▀▀ █▌ ██▀▀█▄ ▐█
▄▄██▀▀█▄▄▄ ██ ██ █▀▀█ ▐█▀▀██ ▄█▀▀█ █▀▀
█▌ ▄▌ ▐█ █▌ ▀█▄▄▄█▌ █ █ ▐█ ██ ██▀▀ █
██████▀▄█ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀▀ ▀▀▀▀ ▀
`);
const element = document.getElementById("root");
if (element === null) {
throw new Error("root element is null");
}
const root = createRoot(element);
root.render(<App />);
};

main();
const element = document.getElementById("root");
if (element === null) {
throw new Error("root element is null");
}
const root = createRoot(element);
root.render(<App />);
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,8 @@ export const UserDropdownContent: FC<UserDropdownContentProps> = ({
<Divider css={{ marginBottom: "0 !important" }} />

<Stack css={styles.info} spacing={0}>
<Tooltip title="Coder Version">
<Tooltip title="Browse the source code">
<a
title="Browse Source Code"
css={[styles.footerText, styles.buildInfo]}
href={buildInfo?.external_url}
target="_blank"
Expand Down
Loading