Created
February 3, 2018 20:01
-
-
Save amitzur/b51a40facdf901a35f2207b1586338b8 to your computer and use it in GitHub Desktop.
Scroll to bottom
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
class ScrollToBottom extends Component { | |
componentDidUpdate() { | |
this.el.scrollTop = this.el.scrollHeight; | |
} | |
render() { | |
const child = React.Children.only(this.props.children); | |
return React.cloneElement(child, { ref: (el) => { this.el = el; } }); | |
} | |
} | |
export default ScrollToBottom; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment