From 0bea7b46c571163b5961e6c2c7d45f261f366be8 Mon Sep 17 00:00:00 2001 From: Teto Gomez Date: Fri, 30 Oct 2020 14:40:43 -0600 Subject: [PATCH] fix(): move function out of hook scope --- .../BackLayer/Liquidity/LiquidityBackLayer.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/routes/Evodex/BackLayer/Liquidity/LiquidityBackLayer.js b/src/routes/Evodex/BackLayer/Liquidity/LiquidityBackLayer.js index 06024ab..5193015 100644 --- a/src/routes/Evodex/BackLayer/Liquidity/LiquidityBackLayer.js +++ b/src/routes/Evodex/BackLayer/Liquidity/LiquidityBackLayer.js @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react' +import React, { useState, useEffect, useCallback } from 'react' import PropTypes from 'prop-types' import clsx from 'clsx' import { useTranslation } from 'react-i18next' @@ -313,19 +313,19 @@ const LiquidityBackLayer = ({ setLoading(false) } - useEffect(() => { - const getCurrentSupply = async () => { - const currentSupply = await evolutiondex.getCurrentSupply( - ual, - youGive.selectValue - ) + const getCurrentSupply = useCallback(async () => { + const currentSupply = await evolutiondex.getCurrentSupply( + ual, + youGive.selectValue + ) - setCurrentSupplyValue(currentSupply) - } + setCurrentSupplyValue(currentSupply) + }, [ual, youGive.selectValue]) + useEffect(() => { getCurrentSupply() setPair(pairs.find((pair) => pair.token === youGive.selectValue)) - }, [pairs, youGive.selectValue]) + }, [pairs, youGive.selectValue, getCurrentSupply]) useEffect(() => { setError('')