Skip to content

Commit

Permalink
Merge pull request #1477 from blockscout/fe-1454
Browse files Browse the repository at this point in the history
fix graphql color mode sync
  • Loading branch information
tom2drum authored Jan 5, 2024
2 parents 55cb598 + 50f66fb commit 4cd9933
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ui/graphQL/GraphQL.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4cd9933

Please sign in to comment.