diff --git a/lib/components/CurrencyTextField/CurrencyTextField.tsx b/lib/components/CurrencyTextField/CurrencyTextField.tsx index e163319..b4eeb56 100644 --- a/lib/components/CurrencyTextField/CurrencyTextField.tsx +++ b/lib/components/CurrencyTextField/CurrencyTextField.tsx @@ -149,9 +149,11 @@ export const CurrencyTextField: React.FC = ({ precision: precision, }); - onChange?.(dineroValue, values.formattedValue); + if (!dineroValue.equalsTo(internalValue)) { + onChange?.(dineroValue, values.formattedValue); - setInternalValue(dineroValue); + setInternalValue(dineroValue); + } }; /** diff --git a/src/App.tsx b/src/App.tsx index d1d27be..5e5b42c 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,7 +5,7 @@ import { Box, Button, Typography } from '@mui/material'; export const App: React.FC = () => { const [brutto, setBrutto] = React.useState( - Dinero({ amount: 133742, currency: 'EUR', precision: 2 }), + Dinero({ amount: 5000, currency: 'EUR', precision: 2 }), ); return ( @@ -38,6 +38,15 @@ export const App: React.FC = () => { > 50 € hinzufügen + Dinero amount: {brutto.getAmount()} );