diff --git a/web/src/ui/roomlist/RoomList.tsx b/web/src/ui/roomlist/RoomList.tsx index 38579fd..90833d1 100644 --- a/web/src/ui/roomlist/RoomList.tsx +++ b/web/src/ui/roomlist/RoomList.tsx @@ -13,7 +13,7 @@ // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -import React, { use, useMemo } from "react" +import React, { use, useCallback } from "react" import type { RoomID } from "../../api/types" import { useNonNullEventAsState } from "../../util/eventdispatcher.ts" import { ClientContext } from "../ClientContext.ts" @@ -26,7 +26,7 @@ interface RoomListProps { const RoomList = ({ setActiveRoom }: RoomListProps) => { const roomList = useNonNullEventAsState(use(ClientContext)!.store.roomList) - const clickRoom = useMemo(() => (evt: React.MouseEvent) => { + const clickRoom = useCallback((evt: React.MouseEvent) => { const roomID = evt.currentTarget.getAttribute("data-room-id") if (roomID) { setActiveRoom(roomID) diff --git a/web/src/ui/timeline/TimelineView.tsx b/web/src/ui/timeline/TimelineView.tsx index b17ee19..b2cb62c 100644 --- a/web/src/ui/timeline/TimelineView.tsx +++ b/web/src/ui/timeline/TimelineView.tsx @@ -13,7 +13,7 @@ // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -import { use, useEffect, useMemo, useRef } from "react" +import { use, useCallback, useEffect, useRef } from "react" import { RoomStateStore } from "../../api/statestore.ts" import { useNonNullEventAsState } from "../../util/eventdispatcher.ts" import { ClientContext } from "../ClientContext.ts" @@ -27,7 +27,7 @@ interface TimelineViewProps { const TimelineView = ({ room }: TimelineViewProps) => { const timeline = useNonNullEventAsState(room.timeline) const client = use(ClientContext)! - const loadHistory = useMemo(() => () => { + const loadHistory = useCallback(() => { client.loadMoreHistory(room.roomID) .catch(err => console.error("Failed to load history", err)) }, [client, room.roomID]) @@ -39,7 +39,7 @@ const TimelineView = ({ room }: TimelineViewProps) => { // When the user scrolls the timeline manually, remember if they were at the bottom, // so that we can keep them at the bottom when new events are added. - const handleScroll = useMemo(() => () => { + const handleScroll = useCallback(() => { if (!timelineViewRef.current) { return }