diff --git a/src/AddressTransactions.tsx b/src/AddressTransactions.tsx index 076d9be..4727f7c 100644 --- a/src/AddressTransactions.tsx +++ b/src/AddressTransactions.tsx @@ -154,7 +154,7 @@ const AddressTransactions: React.FC = () => { const [feeDisplay, feeDisplayToggler] = useFeeToggler(); - const selection = useSelection(); + const selectionCtx = useSelection(); return ( @@ -207,7 +207,7 @@ const AddressTransactions: React.FC = () => { feeDisplayToggler={feeDisplayToggler} /> {controller ? ( - + {controller.getPage().map((tx) => ( { const [feeDisplay, feeDisplayToggler] = useFeeToggler(); - const selection = useSelection(); + const selectionCtx = useSelection(); return ( @@ -145,7 +145,7 @@ const BlockTransactions: React.FC = () => { feeDisplayToggler={feeDisplayToggler} /> {page ? ( - + {page.map((tx) => ( = ({ + address, + children, +}) => { + const [selection, setSelection] = useSelectionContext(); + const select = () => { + setSelection({ type: "address", content: address }); + }; + const deselect = () => { + setSelection(null); + }; + + return ( +
+ {children} +
+ ); +}; + +export default AddressHighlighter; diff --git a/src/search/TransactionItem.tsx b/src/search/TransactionItem.tsx index 516554f..ca4fbed 100644 --- a/src/search/TransactionItem.tsx +++ b/src/search/TransactionItem.tsx @@ -6,6 +6,7 @@ import BlockLink from "../components/BlockLink"; import TransactionLink from "../components/TransactionLink"; import AddressOrENSName from "../components/AddressOrENSName"; import TimestampAge from "../components/TimestampAge"; +import AddressHighlighter from "../components/AddressHighlighter"; import TransactionDirection, { Direction, Flags, @@ -14,7 +15,6 @@ import TransactionValue from "../components/TransactionValue"; import { ENSReverseCache, ProcessedTransaction } from "../types"; import { FeeDisplay } from "./useFeeToggler"; import { formatValue } from "../components/formatter"; -import { useSelectionContext } from "../useSelection"; type TransactionItemProps = { tx: ProcessedTransaction; @@ -46,14 +46,6 @@ const TransactionItem: React.FC = ({ const ensTo = ensCache && tx.to && ensCache[tx.to]; const flash = tx.gasPrice.isZero() && tx.internalMinerInteraction; - const [selection, setSelection] = useSelectionContext(); - const select = (address: string) => { - setSelection({ type: "address", content: address }); - }; - const deselect = () => { - setSelection(null); - }; - return (
= ({ {tx.from && ( -
select(tx.from!)} - onMouseLeave={deselect} - > + -
+ )}
@@ -107,24 +89,14 @@ const TransactionItem: React.FC = ({ {tx.to && ( -
select(tx.to!)} - onMouseLeave={deselect} - > + -
+ )}