mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 15:36:02 +01:00
perf(web/menu): memoize button and header components
Drops the render times for a 9 button menu down from 12ms to 1.6ms
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { Box, Text } from '@chakra-ui/react';
|
import { Box, Text } from '@chakra-ui/react';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
const Header: React.FC<{ title: string }> = ({ title }) => {
|
const Header: React.FC<{ title: string }> = ({ title }) => {
|
||||||
return (
|
return (
|
||||||
@@ -18,4 +19,4 @@ const Header: React.FC<{ title: string }> = ({ title }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Header;
|
export default React.memo(Header);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Box, Flex, Stack, Text } from '@chakra-ui/react';
|
import { Box, Flex, Stack, Text } from '@chakra-ui/react';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { forwardRef } from 'react';
|
import React, { forwardRef } from 'react';
|
||||||
import CustomCheckbox from './CustomCheckbox';
|
import CustomCheckbox from './CustomCheckbox';
|
||||||
import type { MenuItem } from './index';
|
import type { MenuItem } from './index';
|
||||||
|
|
||||||
@@ -68,4 +68,4 @@ const ListItem = forwardRef<Array<HTMLDivElement | null>, Props>(({ item, index,
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
export default ListItem;
|
export default React.memo(ListItem);
|
||||||
|
|||||||
Reference in New Issue
Block a user