Skip to content

Commit 56144e4

Browse files
clear error on input change
1 parent 36eb604 commit 56144e4

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/theme/Footer/Layout/index.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ interface FooterStats {
1313
supportHours: string;
1414
}
1515

16+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
17+
1618
export default function FooterLayout({
1719
style,
1820
links,
@@ -53,13 +55,12 @@ export default function FooterLayout({
5355

5456
fetchStats();
5557
const interval = setInterval(fetchStats, 30000); // Update every 30 seconds
56-
58+
5759
return () => clearInterval(interval);
5860
}, []);
59-
61+
6062
const handleSubscribe = (e: React.FormEvent) => {
6163
e.preventDefault();
62-
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
6364

6465
if (!email) {
6566
setError("Email is required");
@@ -354,7 +355,10 @@ export default function FooterLayout({
354355
placeholder="[email protected]"
355356
className="newsletter-input"
356357
value={email}
357-
onChange={(e) => setEmail(e.target.value)}
358+
onChange={(e) => {
359+
setEmail(e.target.value);
360+
setError("");
361+
}}
358362
required
359363
/>
360364
<button

0 commit comments

Comments
 (0)