Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/components/CurrencyTextField/CurrencyTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,11 @@ export const CurrencyTextField: React.FC<CurrencyTextFieldProps> = ({
precision: precision,
});

onChange?.(dineroValue, values.formattedValue);
if (!dineroValue.equalsTo(internalValue)) {
onChange?.(dineroValue, values.formattedValue);

setInternalValue(dineroValue);
setInternalValue(dineroValue);
}
};

/**
Expand Down
11 changes: 10 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Box, Button, Typography } from '@mui/material';

export const App: React.FC = () => {
const [brutto, setBrutto] = React.useState<Dinero.Dinero>(
Dinero({ amount: 133742, currency: 'EUR', precision: 2 }),
Dinero({ amount: 5000, currency: 'EUR', precision: 2 }),
);

return (
Expand Down Expand Up @@ -38,6 +38,15 @@ export const App: React.FC = () => {
>
50 € hinzufügen
</Button>
<Button
variant="contained"
color="primary"
onClick={() => {
setBrutto(() => Dinero({ amount: 5000, currency: 'EUR' }));
}}
>
Auf 50 € setzen
</Button>
<Typography>Dinero amount: {brutto.getAmount()}</Typography>
</Box>
);
Expand Down
Loading