refactor: memoize icons on export

This commit is contained in:
rusconn
2023-06-24 09:26:37 +09:00
parent 257080b00d
commit 240fba0e74
14 changed files with 74 additions and 101 deletions

View File

@@ -1,4 +1,4 @@
import { useCallback, useMemo, useRef } from "react";
import { useCallback, useRef } from "react";
import { icons } from "@/components/icons";
@@ -55,11 +55,14 @@ export function FileButton({
[maxFileSizeMb, onFileRead]
);
const icon = useMemo(() => <icons.File size={16} />, []);
return (
<>
<BaseButton {...props} {...{ icon, iconOnly, onClick }} labelText="Load a file" />
<BaseButton
{...props}
icon={<icons.File size={16} />}
{...{ iconOnly, onClick }}
labelText="Load a file"
/>
<input hidden type="file" {...{ ref, accept, onChange }} />
</>
);