diff options
author | Francesco <firefelix@gmail.com> | 2015-06-09 16:53:04 +0200 |
---|---|---|
committer | Francesco <firefelix@gmail.com> | 2015-06-09 16:53:04 +0200 |
commit | a54e39b4db5f845841f1258b7398f24d0b1b8117 (patch) | |
tree | a44b31c9e9aa728afa777e142b2e20fb966e480a /lib/TextareaAutosize.js | |
parent | 472048d2afd6ede93715cd20fe20156ba6e679f0 (diff) | |
download | react-autosize-textarea-a54e39b4db5f845841f1258b7398f24d0b1b8117.zip react-autosize-textarea-a54e39b4db5f845841f1258b7398f24d0b1b8117.tar.gz react-autosize-textarea-a54e39b4db5f845841f1258b7398f24d0b1b8117.tar.bz2 |
Initial Commitv0.1.0
Diffstat (limited to 'lib/TextareaAutosize.js')
-rw-r--r-- | lib/TextareaAutosize.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/TextareaAutosize.js b/lib/TextareaAutosize.js new file mode 100644 index 0000000..c7a68df --- /dev/null +++ b/lib/TextareaAutosize.js @@ -0,0 +1,35 @@ +'use strict'; + +const React = require('react'), + autosize = require('autosize'); + +const TextareaAutosize = React.createClass({ + + propTypes: { + onResize: React.PropTypes.func + }, + + getDefaultProps() { + return { + rows: 1 + }; + }, + + componentDidMount() { + autosize(this.refs.textarea.getDOMNode()); + if (this.props.onResize) { + this.refs.textarea.getDOMNode().addEventListener('autosize:resized', this.props.onResize); + } + }, + + render() { + return ( + <textarea {...this.props} ref='textarea'> + {this.props.children} + </textarea> + ); + } + +}); + +module.exports = TextareaAutosize;
\ No newline at end of file |