-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtextInput.js
More file actions
40 lines (34 loc) · 968 Bytes
/
textInput.js
File metadata and controls
40 lines (34 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';
var React = require('react');
var Input = React.createClass({
propTypes: {
name: React.PropTypes.string.isRequired,
label: React.PropTypes.string.isRequired,
onChange: React.PropTypes.func.isRequired,
placeholder: React.PropTypes.string,
value: React.PropTypes.string,
error: React.PropTypes.string
},
render: function () {
var wrapperClass = 'form-group';
if (this.props.error && this.props.error.lenght > 0){
wrapperClass += ' ' + 'has-error';
}
return (
<div className={wrapperClass}>
<label htmlFor={this.props.name}>{this.props.label}</label>
<div className="field">
<input type="text"
name={this.props.name}
className="form-control"
placeholder={this.props.placeholder}
ref={this.props.name}
value={this.props.firstName}
onChange={this.props.onChange} />
<div className="input">{this.props.error}</div>
</div>
</div>
);
}
});
module.exports = Input;