I'm new to react, I would like a div to scroll up as it starts to overflow, and I am trying to do it the proper way with react, but can't seem to figure it out.
I have the following in my render method:
render:function(){
return (
<div className="main">
<div className="title">talkin folk</div>
<div className="chatBox">
<div className="chatRooms">
<p className="large">rooms</p>
{this.arrayOfRooms}
</ div>
<div className="typingBox">
<div ref='dialog' key='dialog' className="dialog"> // div to scroll
{this.arrayOfMsgToRender}
</div>
<div className="userType">
<input
type="text"
placeholder="You:"
label="email"
value={this.state.msg}
onChange={this.handleInput}
/>
<input id="doneButton" type="submit" value="send" onClick={this.handleSend} />
</div>
</ div>
</ div>
</ div>
);
}
In the above code, it is the div dialog, that I would like to have scroll up automatically as it starts to overflow.
I tried to do something like:
componentDidUpdate: function() {
var node = this.getDOMNode('dialog');
node.scrollTop = node.scrollHeight;
},
But that wont work