Update components/TransactionsNavigationHeader.tsx

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
Marcos Rodriguez Vélez 2024-09-27 00:00:49 -04:00 committed by GitHub
parent d9f4ad6d39
commit 01dd629c17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -160,14 +160,22 @@ const TransactionsNavigationHeader: React.FC<TransactionsNavigationHeaderProps>
}
}, [wallet.type]);
// Custom hook to store previous value
const usePrevious = (value: any) => {
const ref = useRef();
useEffect(() => {
ref.current = value;
}, [value]);
return ref.current;
};
// Custom hook to store previous value
const usePrevious = <T>(value: T): T | undefined => {
const ref = useRef<T>();
useEffect(() => {
ref.current = value;
}, [value]);
return ref.current;
};
const TransactionsNavigationHeader: React.FC<TransactionsNavigationHeaderProps> = ({
wallet: initialWallet,
onWalletUnitChange,
onManageFundsPressed,
onWalletBalanceVisibilityChange,
unit = BitcoinUnit.BTC,
}) => {
// Use previous values to determine if updates have occurred
const prevBalance = usePrevious(balance);