Answer the question
In order to leave comments, you need to log in
React refs and element height???
The rest of the chat window, I want to push the scroll to the bottom of the component and use react.React.createRef() to create this.windowRef.scrollTop = this.windowRef.scrollHeight on didMount and DidUpdate
constructor(props) {
super(props);
this.windowRef = React.createRef();
}
componentDidMount() {
const wind = document.querySelector('#window');
console.log(wind.scrollHeight);
this.windowRef.scrollTop = this.windowRef.scrollHeight;
}
componentDidUpdate() {
this.windowRef.scrollTop = this.windowRef.scrollHeight;
console.log(this.windowRef.scrollHeight);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question