Skip to content

Commit 05e3110

Browse files
committed
fix: update pathnameRef synchronously during render to avoid stale read
1 parent dea02d4 commit 05e3110

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

apps/web/src/routes/__root.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,9 @@ function EventRouter() {
156156
const navigate = useNavigate();
157157
const pathname = useRouterState({ select: (state) => state.location.pathname });
158158
const pathnameRef = useRef(pathname);
159+
pathnameRef.current = pathname;
159160
const handledBootstrapThreadIdRef = useRef<string | null>(null);
160161

161-
useEffect(() => {
162-
pathnameRef.current = pathname;
163-
}, [pathname]);
164-
165162
useEffect(() => {
166163
const api = readNativeApi();
167164
if (!api) return;

0 commit comments

Comments
 (0)