From 50f66fbdee2b94fd0dfab3db238ff295c9f93ed9 Mon Sep 17 00:00:00 2001 From: isstuev Date: Thu, 4 Jan 2024 16:20:30 +0100 Subject: [PATCH] fix graphql color mode sync --- ui/graphQL/GraphQL.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ui/graphQL/GraphQL.tsx b/ui/graphQL/GraphQL.tsx index 2587ec5439..575fc2724c 100644 --- a/ui/graphQL/GraphQL.tsx +++ b/ui/graphQL/GraphQL.tsx @@ -20,18 +20,19 @@ const GraphQL = () => { const { colorMode } = useColorMode(); + const graphqlTheme = window.localStorage.getItem('graphiql:theme'); + // colorModeState used as a key to re-render GraphiQL conponent after color mode change - const [ colorModeState, setColorModeState ] = React.useState(colorMode); + const [ colorModeState, setColorModeState ] = React.useState(graphqlTheme); React.useEffect(() => { if (isBrowser()) { - const graphqlTheme = window.localStorage.getItem('graphiql:theme'); if (graphqlTheme !== colorMode) { window.localStorage.setItem('graphiql:theme', colorMode); setColorModeState(colorMode); } } - }, [ colorMode ]); + }, [ colorMode, graphqlTheme ]); if (!feature.isEnabled) { return null;