From 32a93e211f487604197c0429b819f5fd509d0642 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 24 Aug 2022 04:44:18 -0300 Subject: [PATCH] Extract title into effect --- src/Transaction.tsx | 8 +++++++- src/useErigonHooks.ts | 2 -- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Transaction.tsx b/src/Transaction.tsx index 13a901a..4c2596a 100644 --- a/src/Transaction.tsx +++ b/src/Transaction.tsx @@ -1,4 +1,4 @@ -import React, { useContext } from "react"; +import React, { useContext, useEffect } from "react"; import { useParams, Route, Routes } from "react-router-dom"; import { Tab } from "@headlessui/react"; import StandardFrame from "./StandardFrame"; @@ -25,6 +25,12 @@ const Transaction: React.FC = () => { const txData = useTxData(provider, txHash); const selectionCtx = useSelection(); + useEffect(() => { + if (txData) { + document.title = `Transaction ${txData.transactionHash} | Otterscan`; + } + }, [txData]); + return ( diff --git a/src/useErigonHooks.ts b/src/useErigonHooks.ts index 7de952a..50663ce 100644 --- a/src/useErigonHooks.ts +++ b/src/useErigonHooks.ts @@ -207,8 +207,6 @@ export const useTxData = ( return; } - document.title = `Transaction ${_response.hash} | Otterscan`; - setTxData({ transactionHash: _response.hash, from: _response.from,