...

/

Tweak: Scroll Removal for New Messages

Tweak: Scroll Removal for New Messages

This focuses more on the React DOM instead of Redux. We need to create a ref for the Chat DOM and add commands for two instances: componentDidMount() and componentDidUpdate().

We'll cover the following...

Let’s make sure the chat window scrolls when updated.

To do this we’ll need a bit of DOM manipulation. This is the reason I insisted on making <Chats /> a class component.

Okay, let’s talk code.

Firstly, we need to create a Ref to hold the Chats DOM Node.

Press + to interact
constructor(props) {
super(props);
this.chatsRef = React.createRef();
}

If you’re not familiar with ...