Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: Define the editor theme before rendering (#22402)

Ivan Vasilov694c0e7f7a25
diff --git a/apps/studio/components/interfaces/App/AppBannerWrapper.tsx b/apps/studio/components/interfaces/App/AppBannerWrapper.tsx
index 70fcd7f303b..1d922af9845 100644
--- a/apps/studio/components/interfaces/App/AppBannerWrapper.tsx
+++ b/apps/studio/components/interfaces/App/AppBannerWrapper.tsx
@@ -1,6 +1,6 @@
import { useMonaco } from '@monaco-editor/react'
import { useTheme } from 'next-themes'
-import { PropsWithChildren, useEffect } from 'react'
+import { PropsWithChildren, useMemo } from 'react'
import IncidentBanner from 'components/layouts/AppLayout/IncidentBanner'
import { NoticeBanner } from 'components/layouts/AppLayout/NoticeBanner'
@@ -15,7 +15,9 @@ const AppBannerWrapper = ({ children }: PropsWithChildren<{}>) => {
const ongoingIncident = useFlag('ongoingIncident')
const showNoticeBanner = useFlag('showNoticeBanner')
- useEffect(() => {
+ // Define the supabase theme for Monaco before anything is rendered. Using useEffect would sometime load the theme
+ // after the editor was loaded, so it looked off. useMemo will always be run before rendering
+ useMemo(() => {
if (monaco && resolvedTheme) {
const mode: any = getTheme(resolvedTheme)
monaco.editor.defineTheme('supabase', mode)