Skip to content

Commit 52a0a22

Browse files
committed
Destructure props and state in render()
1 parent ea63611 commit 52a0a22

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/index.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,28 +187,29 @@ export default React.createClass({
187187
},
188188

189189
render() {
190-
var {props, state} = this
191-
var hasSelectedOptions = state.selectedValues.length > 0
192-
return <div className={props.className}>
190+
let {filter, filteredOptions, selectedValues} = this.state
191+
let {className, disabled, placeholder, size, textProp, valueProp} = this.props
192+
let hasSelectedOptions = selectedValues.length > 0
193+
return <div className={className}>
193194
<input
194195
type="text"
195196
className={this._getClassName('filter')}
196-
placeholder={props.placeholder}
197-
value={state.filter}
197+
placeholder={placeholder}
198+
value={filter}
198199
onChange={this._onFilterChange}
199200
onKeyPress={this._onFilterKeyPress}
200-
disabled={props.disabled}
201+
disabled={disabled}
201202
/>
202203
<select multiple
203204
ref="select"
204205
className={this._getClassName('select')}
205-
size={props.size}
206-
value={state.selectedValues}
206+
size={size}
207+
value={selectedValues}
207208
onChange={this._updateSelectedValues}
208209
onDoubleClick={this._addSelectedToSelection}
209-
disabled={props.disabled}>
210-
{this.state.filteredOptions.map((option) => {
211-
return <option key={option[props.valueProp]} value={option[props.valueProp]}>{option[props.textProp]}</option>
210+
disabled={disabled}>
211+
{filteredOptions.map((option) => {
212+
return <option key={option[valueProp]} value={option[valueProp]}>{option[textProp]}</option>
212213
})}
213214
</select>
214215
<button type="button"

0 commit comments

Comments
 (0)