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().

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.

Get hands-on with 1200+ tech skills courses.