mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-01-27 17:19:08 +03:00
optimizations
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { memo } from 'react';
|
||||
import type { FC } from 'react';
|
||||
|
||||
import { Paper } from '@mui/material';
|
||||
import type { SxProps, Theme } from '@mui/material/styles';
|
||||
|
||||
import type { RequiredChildrenProps } from 'utils';
|
||||
|
||||
@@ -8,16 +10,19 @@ interface SectionContentProps extends RequiredChildrenProps {
|
||||
id?: string;
|
||||
}
|
||||
|
||||
const SectionContent: FC<SectionContentProps> = (props) => {
|
||||
const { children, id } = props;
|
||||
return (
|
||||
<Paper
|
||||
id={id}
|
||||
sx={{ p: 1.5, m: 1.5, borderRadius: 3, border: '1px solid rgb(65, 65, 65)' }}
|
||||
>
|
||||
{children}
|
||||
</Paper>
|
||||
);
|
||||
// Extract styles to avoid recreation on every render
|
||||
const paperStyles: SxProps<Theme> = {
|
||||
p: 1.5,
|
||||
m: 1.5,
|
||||
borderRadius: 3,
|
||||
border: '1px solid rgb(65, 65, 65)'
|
||||
};
|
||||
|
||||
export default SectionContent;
|
||||
const SectionContent: FC<SectionContentProps> = ({ children, id }) => (
|
||||
<Paper id={id} sx={paperStyles}>
|
||||
{children}
|
||||
</Paper>
|
||||
);
|
||||
|
||||
// Memoize to prevent unnecessary re-renders
|
||||
export default memo(SectionContent);
|
||||
|
||||
Reference in New Issue
Block a user