The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/client/hooks/useClipboardWithToast.js

14 lines
603 B

import { useClipboard, useMutableCallback } from '@rocket.chat/fuselage-hooks';
import { useTranslation } from '../contexts/TranslationContext';
import { useToastMessageDispatch } from '../contexts/ToastMessagesContext';
export default function useClipboardWithToast(text) {
const t = useTranslation();
const dispatchToastMessage = useToastMessageDispatch();
return useClipboard(text, {
onCopySuccess: useMutableCallback(() => dispatchToastMessage({ type: 'success', message: t('Copied') })),
onCopyError: useMutableCallback((e) => dispatchToastMessage({ type: 'error', message: e })),
});
}