Fixed React warnings

This commit is contained in:
Semigradsky 2015-09-10 16:10:17 +03:00
parent 5deb7554c9
commit 8fe0d4d73f
1 changed files with 3 additions and 4 deletions

View File

@ -12,9 +12,8 @@ const MySelect = React.createClass({
const className = this.props.className + ' ' + (this.showRequired() ? 'required' : this.showError() ? 'error' : null);
const errorMessage = this.getErrorMessage();
const value = this.getValue();
const options = this.props.options.map(option => (
<option value={option.value} selected={value === option.value ? 'selected' : null}>
const options = this.props.options.map((option, i) => (
<option key={option.title+option.value} value={option.value}>
{option.title}
</option>
));
@ -22,7 +21,7 @@ const MySelect = React.createClass({
return (
<div className='form-group'>
<label htmlFor={this.props.name}>{this.props.title}</label>
<select name={this.props.name} onChange={this.changeValue}>
<select name={this.props.name} onChange={this.changeValue} value={this.getValue()}>
{options}
</select>
<span className='validation-error'>{errorMessage}</span>