From ff26bc203ebe589a097f904667d5c739884626ca Mon Sep 17 00:00:00 2001 From: wint <6386129+Wintus@users.noreply.github.com> Date: Fri, 16 Jan 2026 23:59:46 +0900 Subject: [PATCH 1/2] refactor: remove explicit useMemo in PageTitleInput React Compiler auto-memoizes based on reactive dependencies. Co-Authored-By: Claude --- src/components/PageTitleInput.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/PageTitleInput.tsx b/src/components/PageTitleInput.tsx index 5943cd2..34c1337 100644 --- a/src/components/PageTitleInput.tsx +++ b/src/components/PageTitleInput.tsx @@ -1,4 +1,4 @@ -import { Suspense, useMemo, useState } from 'react'; +import { Suspense, useState } from 'react'; import useDebounce from '../hooks/useDebounce'; import { fetchPageId } from '../services/MediaWikiAPIs'; import { PageIdFetcher } from './PageIdFetcher'; @@ -15,9 +15,8 @@ export function PageTitleInput({ const [pageTitle, setPageTitle] = useState(initialPageTitle); const debouncedPageTitle = useDebounce(pageTitle.trim(), 300); - // Note: useMemo callback cannot be async (linter rule), but returning a Promise is fine. - // Semantically equivalent to async/await, but React wants explicit Promise return. - const pageIdPromise = useMemo(() => { + // React Compiler auto-memoizes based on reactive dependencies (wikiUrl, debouncedPageTitle) + const pageIdPromise = (() => { // guard if (!debouncedPageTitle) { return Promise.resolve({}); @@ -29,7 +28,7 @@ export function PageTitleInput({ console.error('Error fetching page ID:', error); return { error: 'Error fetching page ID. Please try again.' }; }); - }, [wikiUrl, debouncedPageTitle]); + })(); return (