⚡ Bolt: optimize createSortedSectionSelector memoization#49
⚡ Bolt: optimize createSortedSectionSelector memoization#49
Conversation
Wrapped the StarRating functional component in React.memo to prevent unnecessary re-renders. This optimization is targeted at its usage within list components like BookRow, where parent state changes would previously cause every StarRating instance to re-render, even if its props were unchanged. This improves UI performance by reducing the number of wasted render cycles.
…7328919 ⚡ Bolt: Memoize StarRating component to prevent re-renders
Optimized createSortedSectionSelector to only depend on the relevant slice of state. This prevents unnecessary re-sorting of items when unrelated parts of the Redux state change, significantly improving performance as this selector is used in many connectors. - Changed input selector from (state) => state to (state) => getSectionState(state, section, true). - Added safety check for undefined sectionState or items. - Verified with eslint. Co-authored-by: Smensink <41000986+Smensink@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What: Optimized
createSortedSectionSelectorto use a specific state slice as an input selector instead of the entire state tree.🎯 Why: Previously,$O(N \log N)$ sort operation. Since this selector is used in many Redux-connected components, this was a significant performance bottleneck.
createSortedSectionSelectorused(state) => stateas its input selector. This meant that any change to any part of the Redux state would cause the selector to re-run its result function, which includes an📊 Impact: Significantly reduces unnecessary CPU work during Redux state updates. Sorting will now only occur when the specific slice of state (e.g.,
settings.indexers) actually changes.🔬 Measurement: Logic verification and code review confirms that
reselectwill now correctly memoize the sorted result based on the specific section state reference. Verified that no linting errors were introduced.PR created automatically by Jules for task 2192425361291179767 started by @Smensink