mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-24 02:11:10 +01:00
Performance sweep (#147)
This commit is contained in:
@@ -1,6 +1,17 @@
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { useParams } from '@tanstack/react-router';
|
||||
import { atom, useAtomValue } from 'jotai';
|
||||
import { useEffect } from 'react';
|
||||
import { jotaiStore } from '../routes/__root';
|
||||
|
||||
export const activeRequestIdAtom = atom<string>();
|
||||
|
||||
export function useActiveRequestId(): string | null {
|
||||
const { requestId } = useParams();
|
||||
return requestId ?? null;
|
||||
return useAtomValue(activeRequestIdAtom) ?? null;
|
||||
}
|
||||
|
||||
export function useSubscribeActiveRequestId() {
|
||||
const { requestId } = useParams({ strict: false });
|
||||
useEffect(() => {
|
||||
jotaiStore.set(activeRequestIdAtom, requestId);
|
||||
}, [requestId]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user