fix expenses list performance + dom nesting
- memoize accordion cards and groupByMonth so toggling one expense re-renders O(1) cards instead of the whole list - cache Intl.NumberFormat and date formatters per key (was ~2-3 instantiations per item per render) - unmount collapsed accordion details via unmountOnExit to cut initial mount cost and input delay - restructure Account row in ExpenseDetail so Chip is not nested inside <p> (fixes validateDOMNesting warning) - avoid mutating expenses state array when sorting
This commit is contained in:
@@ -33,17 +33,19 @@ export function ExpenseDetail({ item }: { item: ExpenseItem }) {
|
||||
<Row
|
||||
label="Account"
|
||||
value={
|
||||
<Typography variant="body2">
|
||||
{account ? `${account.name}${last4 ? ` (${last4})` : ""}` : "—"}
|
||||
<Box sx={{ display: "flex", alignItems: "center", flexWrap: "wrap", gap: 1 }}>
|
||||
<Typography component="span" variant="body2">
|
||||
{account ? `${account.name}${last4 ? ` (${last4})` : ""}` : "—"}
|
||||
</Typography>
|
||||
{account?.type && (
|
||||
<Chip
|
||||
size="small"
|
||||
label={account.type.replace(/_/g, " ")}
|
||||
variant="outlined"
|
||||
sx={{ ml: 1.5, fontSize: 11, height: 20 }}
|
||||
sx={{ fontSize: 11, height: 20 }}
|
||||
/>
|
||||
)}
|
||||
</Typography>
|
||||
</Box>
|
||||
}
|
||||
/>
|
||||
<Row
|
||||
|
||||
Reference in New Issue
Block a user