Small performance fix for random quote fetch.

This commit is contained in:
Frank Delaguila
2022-11-08 17:13:46 -07:00
parent 47f4f934cd
commit 86c0fa50a3
3 changed files with 17 additions and 6 deletions

View File

@@ -60,7 +60,7 @@ const Modal = forwardRef<HTMLDivElement, ModalProps>(({modalOpen, toggleModal, c
};
useEffect(() => {
fetch('https://api.quotable.io/random').then( res => res.json() ).then( quote => setRandomQuote(`${quote.content}${quote.author}`));
!card.flavor_text ? fetch('https://api.quotable.io/random').then( res => res.json() ).then( quote => setRandomQuote(`${quote.content}${quote.author}`)) : null;
if( (ref as MutableRefObject<HTMLDivElement>).current ) {
(ref as MutableRefObject<HTMLDivElement>).current.scrollTo(0, 0);
}