Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 22x 246x 246x 246x 59x 59x 59x | import { useEffect } from "react";
import { createFreshGlobalKey, clearGlobalKey } from "./GlobalGroupIdempotencyKey";
// - On mount: clears any existing key, generates a new one; optionally persists in sessionStorage (persist: true)
// - On unmount: clears the key
export const useGlobalGroupIdempotencyKey = (options?: { persist?: boolean, condition?: boolean }) => {
const persist = options?.persist === true;
const condition = options?.condition ?? true;
useEffect(() => {
if (condition) createFreshGlobalKey(persist);
return () => {
clearGlobalKey();
};
}, []);
};
|