@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
22 lines • 1.08 kB
JavaScript
import React, { useMemo } from "react";
import { useMarketByCurrencies } from "../../../dada-client/hooks/useMarketByCurrencies";
const createMarketTrendItem = ({ percent, MarketPercentIndicator, }) => React.createElement(MarketPercentIndicator, { percent: percent });
export const useLeftMarketTrendModule = (currencies, MarketPercentIndicator) => {
const marketByCurrencies = useMarketByCurrencies(currencies);
return useMemo(() => {
return currencies.map(currency => {
const currencyMarket = marketByCurrencies[currency.id];
if (!currencyMarket || currencyMarket.priceChangePercentage24h === undefined) {
return currency;
}
return {
...currency,
leftElement: createMarketTrendItem({
percent: currencyMarket.priceChangePercentage24h,
MarketPercentIndicator,
}),
};
});
}, [currencies, marketByCurrencies, MarketPercentIndicator]);
};
//# sourceMappingURL=useLeftMarketTrendModule.js.map