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

Commit 1894f3c

Browse files
authored
Check if the current state address equals input value before updating 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.
1 parent 8fbfdf2 commit 1894f3c

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
presets: [
3-
['@babel/preset-env', { targets: { node: 'current' } }],
3+
['@babel/preset-env', { targets: '> 3%, not dead' }],
44
'@babel/preset-typescript',
55
'@babel/preset-react',
66
],

src/inputs/AddressInput/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,12 @@ function AddressInput({
143143

144144
// when user switch the network we update the address state
145145
useEffect(() => {
146-
updateAddressState(inputRef.current?.value);
146+
// Because the `address` is going to change after we call `updateAddressState`
147+
// To avoid calling `updateAddressState` twice, we check the value and the current address
148+
const inputValue = inputRef.current?.value;
149+
if (inputValue !== address) {
150+
updateAddressState(inputRef.current?.value);
151+
}
147152
}, [networkPrefix, address, updateAddressState]);
148153

149154
// when user types we update the address state

webpack.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,7 @@ module.exports = {
6262
fs: 'empty',
6363
child_process: 'empty',
6464
},
65+
optimization: {
66+
minimize: false,
67+
},
6568
};

0 commit comments

Comments
 (0)