From ee7941365367db85d5a64944a128cb1142716881 Mon Sep 17 00:00:00 2001 From: Maurice Date: Wed, 18 Nov 2026 21:23:03 +0100 Subject: [PATCH] fix(mobile): keep the navigation rail's list ref stable The rail's list ref was an inline function that set state. React 19 detaches and re-attaches a ref whose function changed, so every commit set the list to null and back and asked for one more render of the rail. The ref is one function for the rail's lifetime now. --- client/src/mobile/components/MRail.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/client/src/mobile/components/MRail.tsx b/client/src/mobile/components/MRail.tsx index 4121a8792..f3cc851c3 100644 --- a/client/src/mobile/components/MRail.tsx +++ b/client/src/mobile/components/MRail.tsx @@ -1,4 +1,4 @@ -import { useLayoutEffect, useRef, useState, type ReactNode, type RefObject } from 'react'; +import { useCallback, useLayoutEffect, useRef, useState, type ReactNode, type RefObject } from 'react'; import { edgeFadeClass, useEdgeFade } from './useEdgeFade'; /** @@ -30,6 +30,13 @@ export function MRail({ useEvenLines(listRef); // On a short window the entries scroll; the cut edge fades, so the foot's entries read as more below. const [list, setList] = useState(null); + // One function for the rail's lifetime: React 19 detaches and attaches a ref + // whose function changed, so an inline one set the state to null and back on + // every render and the trip's rail rendered itself into React's update limit. + const listNode = useCallback((node: HTMLDivElement | null) => { + listRef.current = node; + setList(node); + }, []); const fade = useEdgeFade(list, 'y'); return (