diff options
| author | Xe Iaso <me@xeiaso.net> | 2025-03-25 10:10:02 -0400 |
|---|---|---|
| committer | Xe Iaso <me@xeiaso.net> | 2025-03-25 16:58:59 -0400 |
| commit | 2e080d2fe207c91c9fd6cb49bb0ce2186c19f82d (patch) | |
| tree | 5b788492a2478d7bbdc0d118d94b344b61e5fb77 /docs/src/components/RandomKey | |
| parent | 5b2c0e960d2fdfccf5dcff5d5b259303e697e79d (diff) | |
| download | anubis-2e080d2fe207c91c9fd6cb49bb0ce2186c19f82d.tar.xz anubis-2e080d2fe207c91c9fd6cb49bb0ce2186c19f82d.zip | |
Apply suggestions from code reviewXe/key-bytes-in-flag
Co-authored-by: Ryan Cao <70191398+ryanccn@users.noreply.github.com>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'docs/src/components/RandomKey')
| -rw-r--r-- | docs/src/components/RandomKey/index.tsx | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/docs/src/components/RandomKey/index.tsx b/docs/src/components/RandomKey/index.tsx index f1eb63a..e7ced3e 100644 --- a/docs/src/components/RandomKey/index.tsx +++ b/docs/src/components/RandomKey/index.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect } from "react"; +import { useState, useCallback } from "react"; import Code from "@theme/CodeInline"; import BrowserOnly from "@docusaurus/BrowserOnly"; @@ -20,17 +20,16 @@ export default function RandomKey() { <BrowserOnly fallback={<div>Loading...</div>}> {() => { const [key, setKey] = useState<String>(genRandomKey()); - const [refresh, setRefresh] = useState<number>(0); - useEffect(() => { + const genRandomKeyCb = useCallback(() => { setKey(genRandomKey()); - }, [refresh]); + }); return ( <span> <Code>{key}</Code> <span style={{ marginLeft: "0.25rem", marginRight: "0.25rem" }} /> <button onClick={() => { - setRefresh((n) => n + 1); + genRandomKeyCb(); }} > ♻️ |
