('asc');
const [orderBy, setOrderBy] = React.useState('name');
+
+ const sortedRows = React.useMemo(
+ () => [...data].sort(getComparator(order, orderBy)),
+ [order, orderBy],
+ );
+
const handleRequestSort = (event: React.MouseEvent, property: keyof Data) => {
const isAsc = orderBy === property && order === 'asc';
setOrder(isAsc ? 'desc' : 'asc');
@@ -122,7 +128,7 @@ export default function BasicTable() {
- {[...data].sort(getComparator(order, orderBy)).map((row) => (
+ {sortedRows.map((row) => (
diff --git a/docs/src/modules/components/MaterialShowcase.js b/docs/src/modules/components/MaterialShowcase.js
index df36890c140347..acbf5385b9940a 100644
--- a/docs/src/modules/components/MaterialShowcase.js
+++ b/docs/src/modules/components/MaterialShowcase.js
@@ -462,6 +462,11 @@ export default function Showcase() {
const sortFunction = sortFunctions[sortFunctionName];
const t = useTranslate();
+ const sortedApps = React.useMemo(
+ () => appList.filter((item) => item[sortFunctionName] !== undefined).sort(sortFunction),
+ [sortFunction, sortFunctionName],
+ );
+
const handleChangeSort = (event) => {
setSortFunctionName(event.target.value);
};
@@ -486,100 +491,97 @@ export default function Showcase() {
- {appList
- .filter((item) => item[sortFunctionName] !== undefined)
- .sort(sortFunction)
- .map((app) => (
-
- {app.image ? (
- ({
- height: '100%',
- display: 'flex',
- flexDirection: 'column',
- p: 2,
- gap: 2,
- borderRadius: 1,
- backgroundColor: `${alpha(theme.palette.grey[50], 0.3)}`,
+ {sortedApps.map((app) => (
+
+ {app.image ? (
+ ({
+ height: '100%',
+ display: 'flex',
+ flexDirection: 'column',
+ p: 2,
+ gap: 2,
+ borderRadius: 1,
+ backgroundColor: `${alpha(theme.palette.grey[50], 0.3)}`,
+ borderColor: 'divider',
+ ...theme.applyDarkStyles({
+ backgroundColor: `${alpha(theme.palette.primaryDark[700], 0.2)}`,
borderColor: 'divider',
- ...theme.applyDarkStyles({
- backgroundColor: `${alpha(theme.palette.primaryDark[700], 0.2)}`,
+ }),
+ })}
+ >
+
+ ({
+ height: 'auto',
+ borderRadius: '6px',
+ bgcolor: 'currentColor',
+ border: '1px solid',
borderColor: 'divider',
- }),
- })}
- >
-
- ({
- height: 'auto',
- borderRadius: '6px',
- bgcolor: 'currentColor',
- border: '1px solid',
- borderColor: 'divider',
- color: 'grey.100',
- ...theme.applyDarkStyles({
- color: 'primaryDark.900',
- }),
- })}
- />
-
-
-
- {app.title}
- {app.source ? (
-
-
-
- ) : null}
-
-
- {app.description}
-
-
-
- {app.dateAdded}
-
-
-
- ) : (
-
- {t('visit')}
-
- )}
-
- ))}
+ color: 'grey.100',
+ ...theme.applyDarkStyles({
+ color: 'primaryDark.900',
+ }),
+ })}
+ />
+
+
+
+ {app.title}
+ {app.source ? (
+
+
+
+ ) : null}
+
+
+ {app.description}
+
+
+
+ {app.dateAdded}
+
+
+
+ ) : (
+
+ {t('visit')}
+
+ )}
+
+ ))}
);
|