Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Check if the current state address equals input value before updating…
Browse files Browse the repository at this point in the history
… address state (#203)

* Check if the current state address equals input value before updating address state

* disable minimizing

* exclude updateAddressState from deps

* Revert "exclude updateAddressState from deps"

This reverts commit 5965f27.
  • Loading branch information
mmv08 authored Jul 12, 2022
1 parent 8fbfdf2 commit 1894f3c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
['@babel/preset-env', { targets: '> 3%, not dead' }],
'@babel/preset-typescript',
'@babel/preset-react',
],
Expand Down
7 changes: 6 additions & 1 deletion src/inputs/AddressInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,12 @@ function AddressInput({

// when user switch the network we update the address state
useEffect(() => {
updateAddressState(inputRef.current?.value);
// Because the `address` is going to change after we call `updateAddressState`
// To avoid calling `updateAddressState` twice, we check the value and the current address
const inputValue = inputRef.current?.value;
if (inputValue !== address) {
updateAddressState(inputRef.current?.value);
}
}, [networkPrefix, address, updateAddressState]);

// when user types we update the address state
Expand Down
3 changes: 3 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,7 @@ module.exports = {
fs: 'empty',
child_process: 'empty',
},
optimization: {
minimize: false,
},
};

0 comments on commit 1894f3c

Please sign in to comment.