Skip to content

Commit

Permalink
Merge pull request #101 from terraswap/feature/ux-improvement
Browse files Browse the repository at this point in the history
fix: set replace flag to setSearchParams
  • Loading branch information
JoowonYun authored May 12, 2022
2 parents 5361ef5 + 14dbe63 commit ee6ca1f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/forms/SwapForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const SwapForm = ({ type, tabs }: { type: Type; tabs: TabViewProps }) => {
if (!from && !to) {
setTimeout(() => {
searchParams.set("from", type === Type.WITHDRAW ? InitLP : ULUNA)
setSearchParams(searchParams)
setSearchParams(searchParams, { replace: true })
}, 100)
}
}, [from, searchParams, setSearchParams, to, type])
Expand All @@ -171,7 +171,7 @@ const SwapForm = ({ type, tabs }: { type: Type; tabs: TabViewProps }) => {
if (isUnable) {
searchParams.set("to", "")
}
setSearchParams(searchParams)
setSearchParams(searchParams, { replace: true })
}
const handleToken2Select = (token: string, isUnable?: boolean) => {
searchParams.set("to", token)
Expand All @@ -181,7 +181,7 @@ const SwapForm = ({ type, tabs }: { type: Type; tabs: TabViewProps }) => {
if (isUnable) {
searchParams.set("from", "")
}
setSearchParams(searchParams)
setSearchParams(searchParams, { replace: true })
}
const handleSwitchToken = () => {
if (!pairSwitchable) {
Expand Down Expand Up @@ -995,7 +995,7 @@ const SwapForm = ({ type, tabs }: { type: Type; tabs: TabViewProps }) => {
onClick: () => {
searchParams.set("to", "")
searchParams.set("from", "")
setSearchParams(searchParams)
setSearchParams(searchParams, { replace: true })
resetField(Key.value1)
resetField(Key.value2)
resetField(Key.feeSymbol)
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Swap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const Swap = () => {
.includes(type)
) {
searchParams.set("type", Type.SWAP)
setSearchParams(searchParams)
setSearchParams(searchParams, { replace: true })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [type])
Expand Down

0 comments on commit ee6ca1f

Please sign in to comment.