Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.

Commit fc1e5b9

Browse files
Kerry Archibaldsandhose
authored andcommitted
useMemo instead of ref
1 parent 0df427d commit fc1e5b9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

frontend/src/components/SessionDetail/SessionDetail.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { Alert } from "@vector-im/compound-web";
1616
import { useAtomValue } from "jotai";
1717
import { atomFamily } from "jotai/utils";
1818
import { atomWithQuery } from "jotai-urql";
19-
import { useRef } from "react";
19+
import { useMemo } from "react";
2020

2121
import { Link } from "../../Router";
2222
import { graphql } from "../../gql/gql";
@@ -48,8 +48,11 @@ const SessionDetail: React.FC<{
4848
deviceId: string;
4949
userId: string;
5050
}> = ({ deviceId, userId }) => {
51-
const props = useRef({ userId, deviceId });
52-
const result = useAtomValue(sessionFamily(props.current));
51+
const sessionFamilyAtomWithProps = useMemo(
52+
() => sessionFamily({ deviceId, userId }),
53+
[deviceId, userId],
54+
);
55+
const result = useAtomValue(sessionFamilyAtomWithProps);
5356

5457
const session = result.data?.session;
5558

0 commit comments

Comments
 (0)