Memoize some components

This commit is contained in:
Jordan Eldredge 2019-12-06 06:22:31 -08:00
parent a09fdaec97
commit 7650554be9
4 changed files with 8 additions and 4 deletions

View file

@ -13,7 +13,7 @@ interface State {
selected: boolean;
}
export default function PlaylistMenu(props: Props) {
function PlaylistMenu(props: Props) {
const [selected, setSelected] = useState(false);
const [ref, setRef] = useState<Element | null>(null);
@ -51,3 +51,4 @@ export default function PlaylistMenu(props: Props) {
</div>
);
}
export default React.memo(PlaylistMenu);

View file

@ -7,7 +7,7 @@ interface Props {
}
// We implement hover ourselves, because we hate ourselves and https://stackoverflow.com/a/13259049/1263117
export default function PlaylistMenuEntry({ children }: Props) {
function PlaylistMenuEntry({ children }: Props) {
const { ref, hover } = useIsHovered();
return (
<li ref={ref} className={classnames({ hover })}>
@ -15,3 +15,5 @@ export default function PlaylistMenuEntry({ children }: Props) {
</li>
);
}
export default React.memo(PlaylistMenuEntry);

View file

@ -39,4 +39,4 @@ const ScrollBar = () => {
);
};
export default ScrollBar;
export default React.memo(ScrollBar);

View file

@ -13,7 +13,7 @@ interface Props {
id?: string;
}
export default function ResizeTarget(props: Props) {
function ResizeTarget(props: Props) {
const { currentSize, setWindowSize, widthOnly, ...passThroughProps } = props;
const [mouseDown, setMouseDown] = useState(false);
const [mouseStart, setMouseStart] = useState<null | { x: number; y: number }>(
@ -67,3 +67,4 @@ export default function ResizeTarget(props: Props) {
return <div onMouseDown={handleMouseDown} {...passThroughProps} />;
}
export default React.memo(ResizeTarget);