From fc7de43e168544cd8cd08e405d164379b924102e Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 10 Aug 2020 15:08:37 +0200 Subject: [PATCH] refetch price on network change --- src/components/atoms/Price/index.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/atoms/Price/index.tsx b/src/components/atoms/Price/index.tsx index abb1635c8..938e6f7db 100644 --- a/src/components/atoms/Price/index.tsx +++ b/src/components/atoms/Price/index.tsx @@ -3,7 +3,7 @@ import classNames from 'classnames/bind' import PriceConversion from './Conversion' import styles from './index.module.css' import { formatCurrency } from '@coingecko/cryptoformat' -import { useMetadata } from '@oceanprotocol/react' +import { useMetadata, useOcean } from '@oceanprotocol/react' import { DDO } from '@oceanprotocol/lib' import Loader from '../Loader' import Tooltip from '../Tooltip' @@ -19,7 +19,8 @@ export default function Price({ className?: string small?: boolean }): ReactElement { - const { getBestPrice } = useMetadata(ddo.id) + const { chainId } = useOcean() + const { getBestPrice } = useMetadata() const [price, setPrice] = useState() useEffect(() => { @@ -28,7 +29,7 @@ export default function Price({ setPrice(price) } init() - }, []) + }, [chainId]) const styleClasses = cx({ price: true,