From dd19feb73b90a1b6265813e7b178dc8ecbbc8d1b Mon Sep 17 00:00:00 2001 From: Katerina Koukiou Date: Mon, 15 Apr 2019 09:18:59 +0200 Subject: [PATCH] machines: Do not use .bind() in component handlers Do it once in the constructor, otherwise each change event will needlessly create a copy of the function. --- .../create-vm-dialog/createVmDialog.jsx | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/pkg/machines/components/create-vm-dialog/createVmDialog.jsx b/pkg/machines/components/create-vm-dialog/createVmDialog.jsx index 30f48aa51f63..5cfb809db57c 100644 --- a/pkg/machines/components/create-vm-dialog/createVmDialog.jsx +++ b/pkg/machines/components/create-vm-dialog/createVmDialog.jsx @@ -83,6 +83,8 @@ class CreateVM extends React.Component { }; this.onChangedValue = this.onChangedValue.bind(this); + this.onChangedEventValue = this.onChangedEventValue.bind(this); + this.onChangedEventChecked = this.onChangedEventChecked.bind(this); } onChangedEventValue(key, e) { @@ -232,7 +234,7 @@ class CreateVM extends React.Component { installationSource = ( this.onChangedValue('source', e)} superUser="try" /> ); break; @@ -241,7 +243,7 @@ class CreateVM extends React.Component { installationSource = ( this.onChangedValue('source', e)} superuser="try" /> ); break; @@ -262,7 +264,7 @@ class CreateVM extends React.Component { + onChange={e => this.onChangedValue('source', e)}> {getPXENetworkRows(this.props.nodeDevices, this.props.networks, this.state.connectionName)} @@ -282,7 +284,7 @@ class CreateVM extends React.Component { minLength={1} placeholder={_("Remote URL")} value={this.state.source} - onChange={this.onChangedEventValue.bind(this, 'source')} /> + onChange={e => this.onChangedEventValue('source', e)} /> ); break; } @@ -323,7 +325,7 @@ class CreateVM extends React.Component { minLength={1} value={this.state.vmName || ''} placeholder={_("Unique name")} - onChange={this.onChangedEventValue.bind(this, 'vmName')} /> + onChange={e => this.onChangedEventValue('vmName', e)} /> { validationStateName == 'error' &&

{validationFailed.vmName}

@@ -337,7 +339,7 @@ class CreateVM extends React.Component { + onChange={e => this.onChangedValue('sourceType', e)}> {_("Local Install Media")} {_("URL")} @@ -358,7 +360,7 @@ class CreateVM extends React.Component { + onChange={e => this.onChangedValue('vendor', e)}> {vendorSelectEntries} { validationFailed.vendor && this.state.vendor == NOT_SPECIFIED && @@ -372,7 +374,7 @@ class CreateVM extends React.Component { + onChange={e => this.onChangedValue('os', e)}> {osEntries} @@ -382,23 +384,23 @@ class CreateVM extends React.Component { id={"memory-size"} value={this.state.memorySize} initialUnit={this.state.memorySizeUnit} - onValueChange={this.onChangedEventValue.bind(this, 'memorySize')} - onUnitChange={this.onChangedValue.bind(this, 'memorySizeUnit')} /> + onValueChange={e => this.onChangedEventValue('memorySize', e)} + onUnitChange={e => this.onChangedValue('memorySizeUnit', e)} /> {this.state.sourceType != EXISTING_DISK_IMAGE_SOURCE && } + onValueChange={e => this.onChangedEventValue('storageSize', e)} + onUnitChange={e => this.onChangedValue('storageSizeUnit', e)} />}