Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
✍️ Describe your changes
Removing React Virtualized
Previously 'react-virtualized' library was used to optimize the performance of chat message listing. If there were a few thousand messages, browser would perform poorly. Virtualized lists exist to fix such a problem.
However, I decided to remove 'react-virtualized' because of the following reasons.
I noticed that when using
CellMeasurer
component to dynamically size each row (chat msg), performance suffered.Further discssion on the issue can be found at CellMeasurer optimizations bvaughn/react-virtualized#341
react-virtualized.poor.performance.mp4
normal-scroll.mp4
implementing a complex chat system with react-virtualized was a poor dev experience and made the development sluggish.
This however does not mean I intend to give up on the performance. I will first build out chat screen and then find other optimizations after that. It seems offloading some chat messages from the screen could be a solution.
For example, let's say a user is looking at 100 messages at a time. We can store 100 + BUFFER amount of messages in the mobx store and pull the rest from the server as needed and offloading messages outside the visible + BUFFER range.
Other changes
react-window
dependency. It was not used. Forgot to delete it from before.@uidotdev/usehooks
dependency. It was used to replaceAutoSizer
ofreact-virtualized
to dynamically measure the width/height of chat list container. Sincereact-virtualized
is removed, this is also not needed.🎟 ️Issue ticket number and link
closes #1
✅ Checklist before requesting a review