Skip to content
Snippets Groups Projects
Unverified Commit 74060639 authored by Douglas Fabris's avatar Douglas Fabris Committed by GitHub
Browse files

regression: Missing `useCallback` on `useExternalLink` (#29974)

parent 817141dc
No related branches found
No related tags found
No related merge requests found
import { useToastMessageDispatch } from '@rocket.chat/ui-contexts';
import { useCallback } from 'react';
export const useExternalLink = () => {
const dispatchToastMessage = useToastMessageDispatch();
import { InvalidUrlError } from '../lib/errors/InvalidUrlError';
return (url: string | undefined) => {
export const useExternalLink = () => {
return useCallback((url: string | undefined) => {
if (!url) {
dispatchToastMessage({ message: 'Invalid url', type: 'error' });
return;
throw new InvalidUrlError();
}
window.open(url, '_blank', 'noopener noreferrer');
};
}, []);
};
import { RocketChatError } from './RocketChatError';
export class InvalidUrlError extends RocketChatError<'invalid-url'> {
constructor(message = 'Invalid url', details?: string) {
super('invalid-url', message, details);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment