Skip to content

Commit

Permalink
form debugging 2
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmar committed Jul 7, 2023
1 parent 1693a87 commit bfa77cc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/FooterNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,12 @@ function NewsletterForm() {
} | null>(null)

useEffect(() => {
if (email !== prevEmail) {
// Clear response if email field is changed,
// unless field was changed to empty because of successful submission
if (email !== prevEmail && !(response?.type === 'success' && !email)) {
setResponse(null)
}
}, [email, prevEmail])
}, [email, prevEmail, response?.type])

function setError(error: string | Error) {
setResponse({
Expand All @@ -215,6 +217,7 @@ function NewsletterForm() {
(event) => {
event.preventDefault()
setResponse(null)
console.log('response', response)

const formData = new FormData(event.target as HTMLFormElement)

Expand Down

0 comments on commit bfa77cc

Please sign in to comment.