d3george / slash-admin

A modern react admin. It is based on react 18, vite and TypeScript. It's fast !
https://admin.slashspaces.com/
MIT License
1.49k stars 218 forks source link

perf: Throttle Main component's scroll event (150ms) to reduce freque… #63

Closed ntscshen closed 1 month ago

ntscshen commented 2 months ago
  1. add throttling operation in the scroll event of Main component - set 150ms, compared with the previous trigger frequency reduced by about 8 times (i.e., to ensure that the user experience has been the same as before at the same time, but also to avoid triggering the scroll event too frequently, to improve the performance of scrolling)
  2. add event cleanup operation, in the current scenario (Main component always exists in the page, listening to events wrapped by useCallback) theoretically do not clean up the event listener will not cause memory leaks or performance problems, but based on the maintenance point of view, add on is still a good practice, to ensure that in any scenario the code is robust
  3. Remove duplicate state settings setOffsetTop(false) Every time a scroll event is triggered, if the scroll height does not change, there is no need to duplicate the state settings.
vercel[bot] commented 2 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
slash-admin ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 27, 2024 2:04am