Adding check for transaction.id in useTransactionEventFragment hook (#13587)

feature/default_network_editable
Jyoti Puri 3 years ago committed by GitHub
parent 79e96f93db
commit a06a0d21e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      ui/hooks/useTransactionEventFragment.js

@ -1,4 +1,4 @@
import { useCallback, useEffect } from 'react';
import { useCallback } from 'react';
import { useSelector } from 'react-redux';
import { useGasFeeContext } from '../contexts/gasFee';
@ -18,23 +18,20 @@ export const useTransactionEventFragment = () => {
}),
);
useEffect(() => {
if (!fragment && transaction) {
createTransactionEventFragment(
transaction.id,
TRANSACTION_EVENTS.APPROVED,
);
}
}, [fragment, transaction]);
const updateTransactionEventFragment = useCallback(
(params) => {
if (!transaction) {
async (params) => {
if (!transaction || !transaction.id) {
return;
}
if (!fragment) {
await createTransactionEventFragment(
transaction.id,
TRANSACTION_EVENTS.APPROVED,
);
}
updateEventFragment(`transaction-added-${transaction.id}`, params);
},
[transaction],
[fragment, transaction],
);
return {

Loading…
Cancel
Save