Skip to content

Commit

Permalink
perf: do not use React's StrictMode in production
Browse files Browse the repository at this point in the history
Strict mode causes everything to be rendered twice. (I noticed this
because GlobalActions was firing off two request for /previewinfo for
every page change.) This is not particularly efficient, and is
probably not appropriate for the production build.
  • Loading branch information
dairiki committed Sep 19, 2023
1 parent 03d9f46 commit f2d265a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions frontend/js/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ if (dash) {
},
);

root.render(
<StrictMode>
<RouterProvider router={router} />
</StrictMode>,
);
let app = <RouterProvider router={router} />;
if (process.env.NODE_ENV !== "production") {
app = <StrictMode>{app}</StrictMode>;
}
root.render(app);
}

0 comments on commit f2d265a

Please sign in to comment.