Skip to content

Commit

Permalink
Remove useFireChangeOnUnmount
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-jeremy committed Sep 25, 2023
1 parent 8030013 commit 21c74ec
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions packages/desktop-client/src/components/util/AmountInput.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useRef, useState } from 'react';
import React, { useRef, useState } from 'react';

import {
currencyToInteger,
Expand Down Expand Up @@ -56,8 +56,6 @@ export function AmountInput({
}
}

useFireChangeOnUnmount(fireChange, value, negative);

return (
<InputWithContent
id={id}
Expand Down Expand Up @@ -119,21 +117,3 @@ export function BetweenAmountInput({ defaultValue, onChange }) {
</View>
);
}

// Surely there must be a better way...
// Blur does not fire at the moment so I try to save
// when this component is unmounted.
function useFireChangeOnUnmount(fireChange, value, negative) {
let valueRef = useRef(value);
let negativeRef = useRef(negative);
useEffect(() => {
valueRef.current = value;
negativeRef.current = negative;
}, [value, negative]);

useEffect(() => {
return () => {
fireChange(valueRef.current, negativeRef.current);
};
}, []);
}

0 comments on commit 21c74ec

Please sign in to comment.