Commit 50f66fbd authored by isstuev's avatar isstuev

fix graphql color mode sync

parent a078553c
...@@ -20,18 +20,19 @@ const GraphQL = () => { ...@@ -20,18 +20,19 @@ const GraphQL = () => {
const { colorMode } = useColorMode(); const { colorMode } = useColorMode();
const graphqlTheme = window.localStorage.getItem('graphiql:theme');
// colorModeState used as a key to re-render GraphiQL conponent after color mode change // 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(() => { React.useEffect(() => {
if (isBrowser()) { if (isBrowser()) {
const graphqlTheme = window.localStorage.getItem('graphiql:theme');
if (graphqlTheme !== colorMode) { if (graphqlTheme !== colorMode) {
window.localStorage.setItem('graphiql:theme', colorMode); window.localStorage.setItem('graphiql:theme', colorMode);
setColorModeState(colorMode); setColorModeState(colorMode);
} }
} }
}, [ colorMode ]); }, [ colorMode, graphqlTheme ]);
if (!feature.isEnabled) { if (!feature.isEnabled) {
return null; return null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment