refactor: memoize buttons on export

This commit is contained in:
rusconn
2023-06-24 13:58:57 +09:00
parent 240fba0e74
commit 822a8db8f9
13 changed files with 103 additions and 188 deletions

View File

@@ -67,21 +67,15 @@ export default function Page() {
[indentation]
);
const inputPasteButton = useMemo(() => <PasteButton onClipboardRead={setInput} />, []);
const inputPasteButton = <PasteButton onClipboardRead={setInput} />;
const inputFileButton = useMemo(
() => (
<FileButton accept=".json" onFileRead={setInput} iconOnly aria-label="load a json file" />
),
[]
const inputFileButton = (
<FileButton accept=".json" onFileRead={setInput} iconOnly aria-label="load a json file" />
);
const inputClearButton = useMemo(
() => <ClearButton onClick={clearInput} iconOnly aria-label="clear json" />,
[clearInput]
);
const inputClearButton = <ClearButton onClick={clearInput} iconOnly aria-label="clear json" />;
const outputCopyButton = useMemo(() => <CopyButton text={output} />, [output]);
const outputCopyButton = <CopyButton text={output} />;
const inputControl = <ControlMenu list={[inputPasteButton, inputFileButton, inputClearButton]} />;
const outputControl = <ControlMenu list={[outputCopyButton]} />;