File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -15,19 +15,20 @@ export function PageTitleInput({
1515 const [ pageTitle , setPageTitle ] = useState ( initialPageTitle ) ;
1616 const debouncedPageTitle = useDebounce ( pageTitle . trim ( ) , 300 ) ;
1717
18- const pageIdPromise = useMemo ( async ( ) => {
18+ // Note: useMemo callback cannot be async (linter rule), but returning a Promise is fine.
19+ // Semantically equivalent to async/await, but React wants explicit Promise return.
20+ const pageIdPromise = useMemo ( ( ) => {
1921 // guard
2022 if ( ! debouncedPageTitle ) {
21- return { } ;
23+ return Promise . resolve ( { } ) ;
2224 }
2325 // fetch page ID
24- try {
25- const id = await fetchPageId ( wikiUrl , debouncedPageTitle ) ;
26- return { id : id . toString ( ) } ;
27- } catch ( error ) {
28- console . error ( 'Error fetching page ID:' , error ) ;
29- return { error : 'Error fetching page ID. Please try again.' } ;
30- }
26+ return fetchPageId ( wikiUrl , debouncedPageTitle )
27+ . then ( ( id ) => ( { id : id . toString ( ) } ) )
28+ . catch ( ( error ) => {
29+ console . error ( 'Error fetching page ID:' , error ) ;
30+ return { error : 'Error fetching page ID. Please try again.' } ;
31+ } ) ;
3132 } , [ wikiUrl , debouncedPageTitle ] ) ;
3233
3334 return (
You can’t perform that action at this time.
0 commit comments