Skip to content

Commit a33618c

Browse files
committed
hackfix: prevent duplicate toast
1 parent 835bc12 commit a33618c

File tree

1 file changed

+15
-9
lines changed
  • packages/frontend/src/components/ApolloProvider

1 file changed

+15
-9
lines changed

packages/frontend/src/components/ApolloProvider/index.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,21 @@ const ApolloProvider = (props: ApolloProviderProps): React.ReactElement => {
1313

1414
const onError = React.useCallback(
1515
(message: string) => {
16-
toast({
17-
title: message,
18-
description:
19-
'If this error persists, contact us at [email protected].',
20-
status: 'error',
21-
duration: 3000,
22-
isClosable: true,
23-
position: 'top',
24-
})
16+
// HACKFIX: we use this toast.isActive to prevent duplicate toasts from being shown.
17+
// there should be a better way to handle this from the ApolloClient.
18+
const id = `graphql-error-${message.slice(0, 15)}`
19+
if (!toast.isActive(id)) {
20+
toast({
21+
id,
22+
title: message,
23+
description:
24+
'If this error persists, contact us at [email protected].',
25+
status: 'error',
26+
duration: 3000,
27+
isClosable: true,
28+
position: 'top',
29+
})
30+
}
2531
},
2632
[toast],
2733
)

0 commit comments

Comments
 (0)