Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid unnecessary rerenders React components #3124

Merged
merged 23 commits into from
May 27, 2023
Merged
Prev Previous commit
Next Next commit
more
  • Loading branch information
dimaMachina committed May 27, 2023
commit 2994b1a8057744d3c01c84c31afe5391ea6da0f1
11 changes: 5 additions & 6 deletions packages/graphiql/src/components/GraphiQL.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import React, {
ComponentType,
PropsWithChildren,
ReactNode,
useCallback,
useState,
} from 'react';

Expand Down Expand Up @@ -165,6 +166,7 @@ export function GraphiQL({
</GraphiQLProvider>
);
}

// Export main windows/panes to be used separately if desired.
GraphiQL.Logo = GraphiQLLogo;
GraphiQL.Toolbar = GraphiQLToolbar;
Expand Down Expand Up @@ -296,10 +298,7 @@ export function GraphiQLInterface(props: GraphiQLInterfaceProps) {
isChildComponentType(child, GraphiQL.Toolbar),
) || (
<>
<ToolbarButton
onClick={prettify}
label="Prettify query (Shift-Ctrl-P)"
>
<ToolbarButton onClick={prettify} label="Prettify query (Shift-Ctrl-P)">
<PrettifyIcon className="graphiql-toolbar-icon" aria-hidden="true" />
</ToolbarButton>
<ToolbarButton
Expand All @@ -319,11 +318,11 @@ export function GraphiQLInterface(props: GraphiQLInterfaceProps) {
isChildComponentType(child, GraphiQL.Footer),
);

const onClickReference = () => {
const onClickReference = useCallback(() => {
if (pluginResize.hiddenElement === 'first') {
pluginResize.setHiddenElement(null);
}
};
}, [pluginResize]);

const modifier =
window.navigator.platform.toLowerCase().indexOf('mac') === 0 ? (
Expand Down