Fix Lightbox crash

This commit is contained in:
Fedor Indutny 2023-03-16 11:00:41 -07:00 committed by GitHub
parent fd8bd54de5
commit 3d1e2c220e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -86,7 +86,7 @@ export function Lightbox({
hasPrevMessage, hasPrevMessage,
}: PropsType): JSX.Element | null { }: PropsType): JSX.Element | null {
const hasThumbnails = media.length > 1; const hasThumbnails = media.length > 1;
const messageId = media[0].message.id; const messageId = media.at(0)?.message.id;
const prevMessageId = usePrevious(messageId, messageId); const prevMessageId = usePrevious(messageId, messageId);
const needsAnimation = messageId !== prevMessageId; const needsAnimation = messageId !== prevMessageId;
const [root, setRoot] = React.useState<HTMLElement | undefined>(); const [root, setRoot] = React.useState<HTMLElement | undefined>();