UNPKG

844 BJSXView Raw
1// A textarea component
2
3var React = require("react");
4var PropTypes = React.PropTypes;
5
6var TextArea = React.createClass({
7 propTypes: {
8 onChange: PropTypes.func,
9 onFocus: PropTypes.func,
10 className: PropTypes.string,
11 defaultValue: PropTypes.string,
12 placeholder: PropTypes.string,
13 value: PropTypes.string
14 },
15
16 _handleInput: function(e) {
17 var _input = e.target.value;
18 this.props.onChange(_input);
19 },
20
21 getDefaultProps: function() {
22 return {
23 placeholder: "Enter text here..."
24 };
25 },
26
27 render: function() {
28 return (
29 <textarea
30 onChange={this._handleInput}
31 onFocus={this.props.onFocus}
32 value={this.props.value}
33 defaultValue={this.props.defaultValue}
34 placeholder={this.props.placeholder}
35 className={["cb-text-area", this.props.className].join(" ")}
36 />
37 );
38 },
39});
40
41module.exports = TextArea;