class Textarea extends React.Component {
constructor(props) {
super(props);
this.state = {};
this.onChange = this.onChange.bind(this);
}
onChange(e) {
this.setState({
height: e.target.scrollHeight
});
}
render() {
const { height } = this.state;
return (
<div>
<textarea
name="text"
style={{ height }}
placeholder="Autoresize textarea"
onChange={this.onChange}
/>
</div>
)
}
}