I am try to make it automaticly scroll down on every button button click
in ReactJs
what i have tried:
const chat = document.getElementById("ChatArea");
chat.scrollTop = chat.scrollHeight;
the div with the scroll bar:
.ChatArea{
border: 1px solid gray;
width: 50%;
margin: auto;
height: 400px;
display: flex;
flex-direction: column;
overflow-y: scroll;
}
i get the error:
Cannot read properties of null (reading ‘scrollHeight’)