Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

homepage redirect in useLayoutEffect (#70658)

Nick Fitzpatrick21af2827f242
diff --git a/frontend/src/metabase/home/components/HomePage/HomePage.tsx b/frontend/src/metabase/home/components/HomePage/HomePage.tsx
index 199915f89f4..85c3af85b87 100644
--- a/frontend/src/metabase/home/components/HomePage/HomePage.tsx
+++ b/frontend/src/metabase/home/components/HomePage/HomePage.tsx
@@ -1,4 +1,4 @@
-import { useEffect } from "react";
+import { useLayoutEffect } from "react";
import { replace } from "react-router-redux";
import { t } from "ttag";
@@ -30,7 +30,9 @@ const useDashboardRedirect = () => {
const hasDismissedToast = useSelector(getHasDismissedCustomHomePageToast);
const dispatch = useDispatch();
- useEffect(() => {
+ // This redirect must live inside a useLayoutEffect to prevent the browser from painting a frame of <HomeContent>
+ // before firing the redirect (metabase#69917)
+ useLayoutEffect(() => {
if (dashboardId && !isLoading && !dashboard?.archived) {
dispatch(
replace({