-
-
Notifications
You must be signed in to change notification settings - Fork 829
Improve RoomList render time when filtering #5874
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also looks like there's failing end to end tests, which look like legitimate failures
this.dispatcherRef = defaultDispatcher.register(this.onAction); | ||
this.roomStoreToken = RoomViewStore.addListener(this.onRoomViewStoreUpdate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it actually more performant to move things to componentDidMount
? Over the last couple years we've started using the constructor more and more, slowly getting rid of componentDidMount
- putting aside arguments about whether that is correct behaviour, I'm curious if there's a performance impact.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends, generally speaking there can be small performance improvements when the component is rendered but not mounted
But in my opinion the real power of this is that you colocate all your event listeners, if you have some event listeners that you need to place on DOM elements, you will have to perform that in componentDidMount
. And on top of that if it is immediatly followed by componentWillUnmount
you're one step closer to remembering to clean up your listeners
It also helps in tests where you shallow render your components
Overall moving away from lifecycles makes sense, this is pretty much what the React team has been advocating for, but their solution seems to be using hooks instead
I'm not sure how to interpret the screenshot: it looks like we're spending more time in code? Overall this looks sensible, but I am curious how it interacts with the tab indexing/accessibility. It'd also be good to get a comment somewhere in the code to say we deliberately keep the sublists rendered so we don't accidentally optimize it back out 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise lgtm
Improves element-hq/element-web#14750
God speed unleashed when used with element-hq/element-web#16969
Benchmark below
RoomSublist
is quite expensive. It ends up being much cheaper to hide rather than unmounting it when empty. Trading a tiny bit of ram for faster filtering