Skip to content
This repository was archived by the owner on May 1, 2025. It is now read-only.

Commit 8ba5cd1

Browse files
committed
Fixed MultiHash component recreating hashes on urlHash change
1 parent 82a8ca2 commit 8ba5cd1

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/Components/MultiHash.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,16 @@ const MultiHash: FC<MultiHashProps> = ({
8181
}) => {
8282
const { hash: urlHash, pathname } = useLocation();
8383

84-
const hashFuncs: Record<string, () => void> = {};
85-
86-
const defaultOptions = { behavior, position, requiredPathname, scrollFunc };
84+
const defaultOptions = useMemo(
85+
() => ({ behavior, position, requiredPathname, scrollFunc }),
86+
[behavior, position, requiredPathname, scrollFunc]
87+
);
88+
89+
const hashFuncs: Record<string, () => void> = useMemo(() => ({}), [
90+
hashes,
91+
defaultOptions,
92+
pathname,
93+
]);
8794

8895
useMemo(() => {
8996
for (let hash in hashes) {

0 commit comments

Comments
 (0)