mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-17 23:14:03 +01:00
18 lines
535 B
TypeScript
18 lines
535 B
TypeScript
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 {
|
|
return useAtomValue(activeRequestIdAtom) ?? null;
|
|
}
|
|
|
|
export function useSubscribeActiveRequestId() {
|
|
const { requestId } = useParams({ strict: false });
|
|
useEffect(() => {
|
|
jotaiStore.set(activeRequestIdAtom, requestId);
|
|
}, [requestId]);
|
|
}
|