Commit 4cd99338 authored by tom goriunov's avatar tom goriunov Committed by GitHub

Merge pull request #1477 from blockscout/fe-1454

fix graphql color mode sync
parents 55cb5982 50f66fbd
...@@ -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