Skip to content

Commit 017e042

Browse files
committed
docs(examples): fix state and eslint issues
remove state for form input and fix ESLint issues for `with-nextjs-pages-router` example
1 parent 5a77977 commit 017e042

File tree

1 file changed

+3
-5
lines changed
  • examples/with-nextjs-pages-router/src/pages

1 file changed

+3
-5
lines changed

examples/with-nextjs-pages-router/src/pages/index.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import Head from 'next/head';
22
import { useState, type FormEvent } from 'react';
33

44
const Home = () => {
5-
const [query, setQuery] = useState<string>('');
65
const [isLoading, setIsLoading] = useState<boolean>(false);
76
const [result, setResult] = useState<string>('');
87

98
const handleSubmit = async (e: FormEvent<HTMLFormElement>) => {
109
e.preventDefault();
1110
setIsLoading(true);
12-
setQuery('');
11+
const query = new FormData(e.currentTarget).get('query');
12+
e.currentTarget.reset();
1313

1414
try {
1515
const res = await fetch('/api/hyper', {
@@ -44,7 +44,7 @@ const Home = () => {
4444

4545
<p className="mt-4 text-lg">
4646
Type a query in the search bar and press enter to get result of
47-
"string" type
47+
&quot;string&quot; type
4848
</p>
4949

5050
<form onSubmit={handleSubmit}>
@@ -59,8 +59,6 @@ const Home = () => {
5959
id="query"
6060
name="query"
6161
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)}
6462
/>
6563

6664
<button

0 commit comments

Comments
 (0)