From 025e0f213a113f9981de692befef1c479e8b97f4 Mon Sep 17 00:00:00 2001 From: "yongen.loong" Date: Sat, 16 Nov 2024 21:05:09 +0800 Subject: [PATCH] fix: reload after 1s --- components/contract-viewer/index.tsx | 32 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/components/contract-viewer/index.tsx b/components/contract-viewer/index.tsx index 441a98c..e31997e 100644 --- a/components/contract-viewer/index.tsx +++ b/components/contract-viewer/index.tsx @@ -1,11 +1,10 @@ "use client"; -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { useSearchParams } from "next/navigation"; import { useWallet } from "@/data/wallet"; import { ContractView } from "aelf-smartcontract-viewer"; import { useTheme } from "next-themes"; -import { Button } from "../ui/button"; const sideChainTestnetRpc = "https://tdvw-test-node.aelf.io"; @@ -16,25 +15,26 @@ const ContractViewer = ({ name }: { name: string }) => { const contractViewerAddress = searchParams.get("contract-viewer-address"); const [key, setKey] = useState("0"); + useEffect(() => { + setTimeout(() => { + setKey(prev => parseInt(prev) + 1 + ""); + }, 1000); + }, [contractViewerAddress]); + if (!contractViewerAddress || !wallet?.wallet) { return; } return ( - <> -
- -
- - + ); };