fix: unsubscribe from watch order input
This commit is contained in:
@@ -37,6 +37,7 @@ import {
|
||||
usePersistedOrderStoreSubscription,
|
||||
} from '@vegaprotocol/orders';
|
||||
import { OrderType } from '@vegaprotocol/types';
|
||||
import isNumber from 'lodash/isNumber';
|
||||
|
||||
export type TransactionStatus = 'default' | 'pending';
|
||||
|
||||
@@ -82,14 +83,17 @@ export const DealTicket = ({
|
||||
|
||||
const order = watch();
|
||||
|
||||
watch((orderData) => {
|
||||
const persistable = !(
|
||||
orderData.type === OrderType.TYPE_LIMIT && orderData.price === ''
|
||||
);
|
||||
if (persistable) {
|
||||
setPersistedOrder(orderData as DealTicketFormFields);
|
||||
}
|
||||
});
|
||||
useEffect(() => {
|
||||
const { unsubscribe } = watch((orderData) => {
|
||||
const persistable = !(
|
||||
orderData.type === OrderType.TYPE_LIMIT && orderData.price === ''
|
||||
);
|
||||
if (persistable) {
|
||||
setPersistedOrder(orderData as DealTicketFormFields);
|
||||
}
|
||||
});
|
||||
return () => unsubscribe();
|
||||
}, [setPersistedOrder, watch]);
|
||||
|
||||
usePersistedOrderStoreSubscription(market.id, (storedOrder) => {
|
||||
if (order.price !== storedOrder.price) {
|
||||
|
||||
Reference in New Issue
Block a user