Skip to content

Commit

Permalink
Reset form errors on unmount
Browse files Browse the repository at this point in the history
  • Loading branch information
buberdds committed Sep 21, 2023
1 parent 9dfcbf2 commit 99ac05d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useEffect } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { useTranslation } from 'react-i18next'
import { Box } from 'grommet/es6/components/Box'
Expand Down Expand Up @@ -30,6 +31,13 @@ export const UpdatePassword = () => {
)
}

useEffect(() => {
return () => {
console.log('clear')
dispatch(persistActions.resetWrongPassword())
}
}, [dispatch])

return (
<Form<FormValue> onSubmit={onSubmit} {...preventSavingInputsToUserData}>
<Paragraph>
Expand Down
3 changes: 3 additions & 0 deletions src/app/state/persist/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ const persistSlice = createSlice({
deleteProfileAsync(state) {
state.loading = true
},
resetWrongPassword(state) {
state.enteredWrongPassword = false
},
updatePassword(state, action: PayloadAction<UpdatePasswordPayload>) {
return
},
Expand Down

0 comments on commit 99ac05d

Please sign in to comment.