From cdef338c85e3879a97af90f2119351700eaf784e Mon Sep 17 00:00:00 2001 From: David Walsh Date: Thu, 22 Oct 2020 07:50:15 -0500 Subject: [PATCH] Prevent multiple state changes --- .../add-recipient/ens-input.component.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ui/app/pages/send/send-content/add-recipient/ens-input.component.js b/ui/app/pages/send/send-content/add-recipient/ens-input.component.js index f6fdef0e6..0ed9833a4 100644 --- a/ui/app/pages/send/send-content/add-recipient/ens-input.component.js +++ b/ui/app/pages/send/send-content/add-recipient/ens-input.component.js @@ -63,17 +63,21 @@ export default class EnsInput extends Component { value, } = this.props + let newValue + // Set the value of our input based on QR code provided by parent if (input !== value && prevProps.value !== value) { - this.setState({ input: value }) + newValue = value } - // If an address is sent without a nickname, meaning not from ENS or from - // the user's own accounts, a default of a one-space string is used. if (prevProps.network !== network) { const provider = global.ethereumProvider this.ens = new ENS({ provider, network }) - this.onChange({ target: { value: input } }) + newValue = input + } + + if (newValue !== undefined) { + this.onChange({ target: { value: newValue } }) } }