diff --git a/app/converters/number-base/page.tsx b/app/converters/number-base/page.tsx index 05375b3..b2df0c9 100644 --- a/app/converters/number-base/page.tsx +++ b/app/converters/number-base/page.tsx @@ -1,6 +1,6 @@ "use client"; -import { useCallback, useMemo, useState } from "react"; +import { useCallback, useState } from "react"; import { toolGroups } from "@/config/tools"; import * as baselib from "@/lib/base"; @@ -58,25 +58,21 @@ export default function Page() { const onOctChange: InputProps["onChange"] = ({ currentTarget: { value } }) => trySetOct(value); const onBinChange: InputProps["onChange"] = ({ currentTarget: { value } }) => trySetBin(value); - const formatNumberConfig = useMemo( - () => ( - } - title="Format number" - control={ - - } - /> - ), - [format] + const formatNumberConfig = ( + } + title="Format number" + control={ + + } + /> ); - const decPasteButton = ; const hexPasteButton = ; const octPasteButton = ; diff --git a/app/formatters/json/page.tsx b/app/formatters/json/page.tsx index dc0f510..5d39291 100644 --- a/app/formatters/json/page.tsx +++ b/app/formatters/json/page.tsx @@ -1,6 +1,6 @@ "use client"; -import { useCallback, useMemo, useState } from "react"; +import { useCallback, useState } from "react"; import { toolGroups } from "@/config/tools"; import { safeJsonParse } from "@/lib/json"; @@ -41,30 +41,27 @@ export default function Page() { const onJsonChange: EditorProps["onChange"] = value => setInput(value ?? ""); - const indentationConfig = useMemo( - () => ( - } - title="Indentation" - control={ - - } - /> - ), - [indentation] + const indentationConfig = ( + } + title="Indentation" + control={ + + } + /> ); const inputPasteButton = ; diff --git a/app/generators/hash/page.tsx b/app/generators/hash/page.tsx index ce53fa3..ce2ce47 100644 --- a/app/generators/hash/page.tsx +++ b/app/generators/hash/page.tsx @@ -1,6 +1,6 @@ "use client"; -import { useCallback, useMemo, useState } from "react"; +import { useCallback, useState } from "react"; import createHash from "create-hash"; import { toolGroups } from "@/config/tools"; @@ -37,23 +37,20 @@ export default function Page() { const onInputChange: TextareaProps["onChange"] = ({ currentTarget: { value } }) => setInput(value); - const uppercaseConfig = useMemo( - () => ( - } - title="Uppercase" - control={ - - } - /> - ), - [uppercase] + const uppercaseConfig = ( + } + title="Uppercase" + control={ + + } + /> ); const inputPasteButton = ; diff --git a/app/generators/uuid/page.tsx b/app/generators/uuid/page.tsx index c7be4f3..a4497e5 100644 --- a/app/generators/uuid/page.tsx +++ b/app/generators/uuid/page.tsx @@ -48,11 +48,11 @@ export default function Page() { const clearUuids = useCallback(() => setUuids([]), []); - const onUuidVersionChange: SelectProps["onValueChange"] = value => { + const onUuidVersionChange: NonNullable = useCallback(value => { if (uuidVersions.is(value)) { setUuidVersion(value); } - }; + }, []); const onGeneratesChange: InputProps["onChange"] = ({ currentTarget: { value } }) => { const newGenerates = Number(value); @@ -67,67 +67,58 @@ export default function Page() { setUuids([...uuids, ...newUuids]); }; - const hyphensConfig = useMemo( - () => ( - } - title="Hyphens" - control={ - - } - /> - ), - [hyphens] + const hyphensConfig = ( + } + title="Hyphens" + control={ + + } + /> ); - const uppercaseConfig = useMemo( - () => ( - } - title="Uppercase" - control={ - - } - /> - ), - [uppercase] + const uppercaseConfig = ( + } + title="Uppercase" + control={ + + } + /> ); - const uuidVersionConfig = useMemo( - () => ( - } - title="UUID version" - description="Choose the version of UUID to generate" - control={ - - } - /> - ), - [uuidVersion] + const uuidVersionConfig = ( + } + title="UUID version" + description="Choose the version of UUID to generate" + control={ + + } + /> ); const generatesInput = useMemo( diff --git a/app/settings/page.tsx b/app/settings/page.tsx index 537932e..a9d3d77 100644 --- a/app/settings/page.tsx +++ b/app/settings/page.tsx @@ -1,6 +1,5 @@ "use client"; -import { useMemo } from "react"; import { useTheme } from "next-themes"; import { singleTools } from "@/config/tools"; @@ -20,30 +19,27 @@ import { PageSection } from "@/components/page-section"; export default function Page() { const { theme = "system", setTheme } = useTheme(); - const appThemeConfig = useMemo( - () => ( - } - title="App theme" - description="Select which app theme to display" - control={ - - } - /> - ), - [setTheme, theme] + const appThemeConfig = ( + } + title="App theme" + description="Select which app theme to display" + control={ + + } + /> ); return ( diff --git a/components/configuration.tsx b/components/configuration.tsx index 420a1fe..54d900e 100644 --- a/components/configuration.tsx +++ b/components/configuration.tsx @@ -1,3 +1,6 @@ +import { memo } from "react"; +import equal from "react-fast-compare"; + type Props = { icon: React.ReactNode; title: string; @@ -5,7 +8,7 @@ type Props = { control: React.ReactNode; }; -export function Configuration({ icon, title, description, control }: Props) { +function RawConfiguration({ icon, title, description, control }: Props) { return (
{icon} @@ -21,3 +24,5 @@ export function Configuration({ icon, title, description, control }: Props) {
); } + +export const Configuration = memo(RawConfiguration, equal);