Skip to content

Commit

Permalink
perf(web/menu): memoize button and header components
Browse files Browse the repository at this point in the history
Drops the render times for a 9 button menu down from 12ms to 1.6ms
  • Loading branch information
LukeWasTakenn committed Oct 29, 2022
1 parent 6b8cfa9 commit 00465d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion web/src/features/menu/list/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Box, Text } from '@chakra-ui/react';
import React from 'react';

const Header: React.FC<{ title: string }> = ({ title }) => {
return (
Expand All @@ -18,4 +19,4 @@ const Header: React.FC<{ title: string }> = ({ title }) => {
);
};

export default Header;
export default React.memo(Header);
4 changes: 2 additions & 2 deletions web/src/features/menu/list/ListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box, Flex, Stack, Text } from '@chakra-ui/react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { forwardRef } from 'react';
import React, { forwardRef } from 'react';
import CustomCheckbox from './CustomCheckbox';
import type { MenuItem } from './index';

Expand Down Expand Up @@ -68,4 +68,4 @@ const ListItem = forwardRef<Array<HTMLDivElement | null>, Props>(({ item, index,
);
});

export default ListItem;
export default React.memo(ListItem);

0 comments on commit 00465d2

Please sign in to comment.