File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed
examples/with-nextjs-pages-router/src/pages Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -2,14 +2,14 @@ import Head from 'next/head';
2
2
import { useState , type FormEvent } from 'react' ;
3
3
4
4
const Home = ( ) => {
5
- const [ query , setQuery ] = useState < string > ( '' ) ;
6
5
const [ isLoading , setIsLoading ] = useState < boolean > ( false ) ;
7
6
const [ result , setResult ] = useState < string > ( '' ) ;
8
7
9
8
const handleSubmit = async ( e : FormEvent < HTMLFormElement > ) => {
10
9
e . preventDefault ( ) ;
11
10
setIsLoading ( true ) ;
12
- setQuery ( '' ) ;
11
+ const query = new FormData ( e . currentTarget ) . get ( 'query' ) ;
12
+ e . currentTarget . reset ( ) ;
13
13
14
14
try {
15
15
const res = await fetch ( '/api/hyper' , {
@@ -44,7 +44,7 @@ const Home = () => {
44
44
45
45
< p className = "mt-4 text-lg" >
46
46
Type a query in the search bar and press enter to get result of
47
- " string" type
47
+ " string" type
48
48
</ p >
49
49
50
50
< form onSubmit = { handleSubmit } >
@@ -59,8 +59,6 @@ const Home = () => {
59
59
id = "query"
60
60
name = "query"
61
61
className = "ring-2 ring-gray-600 border-gray-600 rounded-md px-2 py-1"
62
- value = { query }
63
- onChange = { ( e ) => setQuery ( e . target . value ) }
64
62
/>
65
63
66
64
< button
You can’t perform that action at this time.
0 commit comments