import React, { useMemo } from "react"; import { useSelectionContext } from "../useSelection"; type AddressHighlighterProps = React.PropsWithChildren<{ address: string; }>; const AddressHighlighter: React.FC = ({ address, children, }) => { const [selection, setSelection] = useSelectionContext(); const [select, deselect] = useMemo(() => { const _select = () => { setSelection({ type: "address", content: address }); }; const _deselect = () => { setSelection(null); }; return [_select, _deselect]; }, [setSelection, address]); return (
{children}
); }; export default React.memo(AddressHighlighter);