File tree Expand file tree Collapse file tree 1 file changed +2
-15
lines changed Expand file tree Collapse file tree 1 file changed +2
-15
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { Copy, CheckCheck } from "lucide-react";
5
5
import { Button } from "@/components/ui/button" ;
6
6
import { useToast } from "@/lib/hooks/useToast" ;
7
7
import { getDataType , tryParseJson } from "@/utils/jsonUtils" ;
8
+ import useCopy from "@/lib/hooks/useCopy" ;
8
9
9
10
interface JsonViewProps {
10
11
data : unknown ;
@@ -25,21 +26,7 @@ const JsonView = memo(
25
26
isError = false ,
26
27
} : JsonViewProps ) => {
27
28
const { toast } = useToast ( ) ;
28
- const [ copied , setCopied ] = useState ( false ) ;
29
-
30
- useEffect ( ( ) => {
31
- let timeoutId : NodeJS . Timeout ;
32
- if ( copied ) {
33
- timeoutId = setTimeout ( ( ) => {
34
- setCopied ( false ) ;
35
- } , 500 ) ;
36
- }
37
- return ( ) => {
38
- if ( timeoutId ) {
39
- clearTimeout ( timeoutId ) ;
40
- }
41
- } ;
42
- } , [ copied ] ) ;
29
+ const { copied, setCopied } = useCopy ( ) ;
43
30
44
31
const normalizedData = useMemo ( ( ) => {
45
32
return typeof data === "string"
You can’t perform that action at this time.
0 commit comments