Commit e8d28615 authored by tom's avatar tom

clean-up

parent 436e889b
import type { UseToastOptions } from '@chakra-ui/react'; import type { UseToastOptions, ToastProps } from '@chakra-ui/react';
import { createToastFn, useChakra } from '@chakra-ui/react'; import { createToastFn, useChakra } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import Toast from 'ui/shared/Toast'; import Toast from 'ui/shared/Toast';
const defaultOptions = { // there is no toastComponent prop in UseToastOptions type
// but these options will be passed to createRenderToast under the hood
// and it accepts custom toastComponent
const defaultOptions: UseToastOptions & { toastComponent?: React.FC<ToastProps> } = {
toastComponent: Toast, toastComponent: Toast,
position: 'top-right', position: 'top-right',
duration: 10000000, duration: 10000000,
...@@ -15,11 +18,7 @@ export default function useToastModified() { ...@@ -15,11 +18,7 @@ export default function useToastModified() {
const { theme } = useChakra(); const { theme } = useChakra();
return React.useMemo( return React.useMemo(
// there is no toastComponent prop in UseToastOptions type () => createToastFn(theme.direction, defaultOptions),
// but these options will be passed to createRenderToast under the hood
// and it accepts custom toastComponent
// so we safely (I hope) do this type conversion
() => createToastFn(theme.direction, defaultOptions as UseToastOptions),
[ theme.direction ], [ theme.direction ],
); );
} }
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