Skip to content

Commit

Permalink
Merge pull request #313 from FormidableLabs/311-fix-invariant
Browse files Browse the repository at this point in the history
Fix invariant on schema explorer
  • Loading branch information
andyrichardson authored Sep 24, 2020
2 parents 472075c + ea2c797 commit 3e2ce5b
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/panel/pages/request/components/Schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ export const Schema: React.FC = () => {
const [stack, setStack] = useState<GraphQLNamedType[]>([]);
const { schema } = useContext(RequestContext);

const isActiveId = useCallback((id) => activeIds.includes(id), [activeIds]);

const handleHeaderClick = useCallback(
(id) => {
if (isActiveId(id)) {
setActiveIds((current) => current.filter((cur) => cur !== id));
} else {
setActiveIds((current) => [id, ...current]);
}
},
[setActiveIds, activeIds, isActiveId]
);

if (schema === undefined) {
return (
<Wrapper>
Expand All @@ -34,19 +47,6 @@ export const Schema: React.FC = () => {
);
}

const isActiveId = useCallback((id) => activeIds.includes(id), [activeIds]);

const handleHeaderClick = useCallback(
(id) => {
if (isActiveId(id)) {
setActiveIds((current) => current.filter((cur) => cur !== id));
} else {
setActiveIds((current) => [id, ...current]);
}
},
[setActiveIds, activeIds, isActiveId]
);

const schemaTypes = schema.getTypeMap();

const setType = (type: GraphQLNamedType) => {
Expand Down

0 comments on commit 3e2ce5b

Please sign in to comment.