Skip to content

Commit

Permalink
Merge pull request #74 from terraswap/feature/19/querystring
Browse files Browse the repository at this point in the history
update: reset form instead location.reload
  • Loading branch information
JoowonYun authored Jan 27, 2022
2 parents 7961c9b + b171c07 commit 4cbebba
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/forms/SwapForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,13 @@ const SwapForm = ({ type, tabs }: { type: Type; tabs: TabViewProps }) => {
mode: "all",
reValidateMode: "onChange",
})
const { register, watch, setValue, setFocus, formState, trigger } = form
const { register, watch, setValue, setFocus, formState, trigger, reset } =
form
const [isReversed, setIsReversed] = useState(false)
const formData = watch()

useEffect(() => {
console.log("setFrom", formData[Key.token1])
setFrom(formData[Key.token1])
console.log("setTo", formData[Key.token2])
setTo(formData[Key.token2])
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [formData])
Expand Down Expand Up @@ -954,7 +953,9 @@ const SwapForm = ({ type, tabs }: { type: Type; tabs: TabViewProps }) => {
{
iconUrl: iconReload,
onClick: () => {
window.location.reload()
reset()
setValue(Key.token1, "")
setValue(Key.token2, "")
},
disabled: formState.isSubmitting,
},
Expand Down

0 comments on commit 4cbebba

Please sign in to comment.