snapshot of https://github.com/mountain-loop/yaak.git (main, 2026-09-23; blobs > 131072B omitted)
This commit is contained in:
8
apps/yaak-client/hooks/useRandomKey.ts
Normal file
8
apps/yaak-client/hooks/useRandomKey.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { useCallback, useState } from "react";
|
||||
import { generateId } from "../lib/generateId";
|
||||
|
||||
export function useRandomKey(initialValue?: string) {
|
||||
const [value, setValue] = useState<string>(initialValue ?? generateId());
|
||||
const regenerate = useCallback(() => setValue(generateId()), []);
|
||||
return [value, regenerate] as const;
|
||||
}
|
||||
Reference in New Issue
Block a user