Skip to content

Commit 0e72763

Browse files
harshsinghatzGuest
andauthored
Fix: mounting state use theme (#7203)
Co-authored-by: Guest <[email protected]>
1 parent 4d2cf28 commit 0e72763

File tree

3 files changed

+10
-30
lines changed

3 files changed

+10
-30
lines changed

apps/web/components/ui/form/Select.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ function Select<
2929
IsMulti extends boolean = false,
3030
Group extends GroupBase<Option> = GroupBase<Option>
3131
>({ className, ...props }: SelectProps<Option, IsMulti, Group>) {
32-
const { resolvedTheme, forcedTheme /*isReady*/ } = useTheme();
32+
const [mounted, setMounted] = useState<boolean>(false);
33+
const { resolvedTheme, forcedTheme } = useTheme();
3334
const hasDarkTheme = !forcedTheme && resolvedTheme === "dark";
3435
const darkThemeColors = {
3536
/** Dark Theme starts */
@@ -73,10 +74,15 @@ function Select<
7374
/** Dark Theme ends */
7475
};
7576

77+
useEffect(() => {
78+
setMounted(true);
79+
}, []);
80+
7681
// Till we know in JS the theme is ready, we can't render react-select as it would render with light theme instead
77-
// if (!isReady) {
78-
// return <input type="text" className={className} />;
79-
// }
82+
if (!mounted) {
83+
return <input type="text" className={className} />;
84+
}
85+
8086
return (
8187
<ReactSelect
8288
theme={(theme) => ({

packages/lib/hooks/useMountedState.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

packages/lib/hooks/useTheme.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@ import { useEffect } from "react";
44
import { useEmbedTheme } from "@calcom/embed-core/embed-iframe";
55
import type { Maybe } from "@calcom/trpc/server";
66

7-
import useMountedState from "./useMountedState";
8-
97
// makes sure the ui doesn't flash
108
export default function useTheme(theme?: Maybe<string>) {
119
let currentTheme: Maybe<string> = theme || "system";
1210

1311
const { resolvedTheme, setTheme, forcedTheme, theme: activeTheme } = useNextTheme();
1412
const embedTheme = useEmbedTheme();
15-
const isMounted = useMountedState();
1613
// Embed UI configuration takes more precedence over App Configuration
1714
currentTheme = embedTheme || theme;
1815

@@ -28,6 +25,5 @@ export default function useTheme(theme?: Maybe<string>) {
2825
setTheme,
2926
forcedTheme,
3027
activeTheme,
31-
isReady: isMounted(),
3228
};
3329
}

0 commit comments

Comments
 (0)