Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
afe30a2c
Unverified
Commit
afe30a2c
authored
Sep 19, 2022
by
vignesh mohankumar
Committed by
GitHub
Sep 19, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: reset Widget amount on URL change (#4668)
* fix: reset Widget amount on URL change * empty
parent
2f9289a2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
inputs.tsx
src/components/Widget/inputs.tsx
+4
-1
No files found.
src/components/Widget/inputs.tsx
View file @
afe30a2c
...
@@ -2,13 +2,15 @@ import { Currency, Field, SwapController, SwapEventHandlers, TradeType } from '@
...
@@ -2,13 +2,15 @@ import { Currency, Field, SwapController, SwapEventHandlers, TradeType } from '@
import
CurrencySearchModal
from
'
components/SearchModal/CurrencySearchModal
'
import
CurrencySearchModal
from
'
components/SearchModal/CurrencySearchModal
'
import
{
useCallback
,
useEffect
,
useMemo
,
useState
}
from
'
react
'
import
{
useCallback
,
useEffect
,
useMemo
,
useState
}
from
'
react
'
const
EMPTY_AMOUNT
=
''
/**
/**
* Integrates the Widget's inputs.
* Integrates the Widget's inputs.
* Treats the Widget as a controlled component, using the app's own token selector for selection.
* Treats the Widget as a controlled component, using the app's own token selector for selection.
*/
*/
export
function
useSyncWidgetInputs
(
defaultToken
?:
Currency
)
{
export
function
useSyncWidgetInputs
(
defaultToken
?:
Currency
)
{
const
[
type
,
setType
]
=
useState
(
TradeType
.
EXACT_INPUT
)
const
[
type
,
setType
]
=
useState
(
TradeType
.
EXACT_INPUT
)
const
[
amount
,
setAmount
]
=
useState
(
''
)
const
[
amount
,
setAmount
]
=
useState
(
EMPTY_AMOUNT
)
const
onAmountChange
=
useCallback
((
field
:
Field
,
amount
:
string
)
=>
{
const
onAmountChange
=
useCallback
((
field
:
Field
,
amount
:
string
)
=>
{
setType
(
toTradeType
(
field
))
setType
(
toTradeType
(
field
))
setAmount
(
amount
)
setAmount
(
amount
)
...
@@ -22,6 +24,7 @@ export function useSyncWidgetInputs(defaultToken?: Currency) {
...
@@ -22,6 +24,7 @@ export function useSyncWidgetInputs(defaultToken?: Currency) {
setTokens
({
setTokens
({
[
Field
.
OUTPUT
]:
defaultToken
,
[
Field
.
OUTPUT
]:
defaultToken
,
})
})
setAmount
(
EMPTY_AMOUNT
)
},
[
defaultToken
])
},
[
defaultToken
])
const
onSwitchTokens
=
useCallback
(()
=>
{
const
onSwitchTokens
=
useCallback
(()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment