Skip to content

Commit

Permalink
feat(neuron-ui): clear send view on wallet switching
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY committed Oct 31, 2019
1 parent aaec8c2 commit 47af746
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/neuron-ui/src/components/Send/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ const clear = (dispatch: StateDispatch) => {
const useClear = (dispatch: StateDispatch) => useCallback(() => clear(dispatch), [dispatch])

export const useInitialize = (
walletID: string,
items: TransactionOutput[],
generatedTx: any | null,
dispatch: React.Dispatch<any>,
Expand All @@ -187,6 +188,10 @@ export const useInitialize = (
const onSubmit = useOnSubmit(items, dispatch)
const onClear = useClear(dispatch)

useEffect(() => {
clear(dispatch)
}, [walletID, dispatch])

const onGetAddressErrorMessage = useCallback(
(addr: string) => {
if (addr === '') {
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-ui/src/components/Send/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const Send = ({
onGetAddressErrorMessage,
onGetAmountErrorMessage,
onClear,
} = useInitialize(send.outputs, send.generatedTx, dispatch, t)
} = useInitialize(walletID, send.outputs, send.generatedTx, dispatch, t)
useOnTransactionChange(walletID, send.outputs, send.price, dispatch, setIsTransactionValid, setTotalAmount)
const leftStackWidth = '70%'
const labelWidth = '140px'
Expand Down

0 comments on commit 47af746

Please sign in to comment.