diff --git a/app/javascript/mastodon/features/collections/detail/index.tsx b/app/javascript/mastodon/features/collections/detail/index.tsx index d2317e716f..0fc13c8f79 100644 --- a/app/javascript/mastodon/features/collections/detail/index.tsx +++ b/app/javascript/mastodon/features/collections/detail/index.tsx @@ -105,8 +105,8 @@ const CollectionHeader: React.FC<{ collection: ApiCollectionJSON }> = ({ ); }, [collection, dispatch]); - const location = useLocation<{ newCollection?: boolean }>(); - const wasJustCreated = location.state.newCollection; + const location = useLocation<{ newCollection?: boolean } | undefined>(); + const wasJustCreated = location.state?.newCollection; useEffect(() => { if (wasJustCreated) { handleShare(); diff --git a/app/javascript/mastodon/features/collections/detail/share_modal.tsx b/app/javascript/mastodon/features/collections/detail/share_modal.tsx index 137794d95b..0f4681d077 100644 --- a/app/javascript/mastodon/features/collections/detail/share_modal.tsx +++ b/app/javascript/mastodon/features/collections/detail/share_modal.tsx @@ -40,8 +40,8 @@ export const CollectionShareModal: React.FC<{ }> = ({ collection, onClose }) => { const intl = useIntl(); const dispatch = useAppDispatch(); - const location = useLocation<{ newCollection?: boolean }>(); - const isNew = !!location.state.newCollection; + const location = useLocation<{ newCollection?: boolean } | undefined>(); + const isNew = !!location.state?.newCollection; const isOwnCollection = collection.account_id === me; const collectionLink = `${window.location.origin}/collections/${collection.id}`;