Commit 50f66fbd authored by isstuev's avatar isstuev

fix graphql color mode sync

parent a078553c
......@@ -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;
......
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