Skip to content

Conversation

@bobnik
Copy link
Collaborator

@bobnik bobnik commented Jan 21, 2026

Selector Optimizations

This PR stabilizes Redux selector references to prevent unnecessary React re-renders, and extracts common selector patterns into shared utilities. The biggest example of this is we no longer re-render the pattern when a user changes the name of a shape.

When unrelated state changes occur, selectors that aggregate data were returning new array/object references even though the contents were identical. This triggered unnecessary downstream recomputation and React re-renders of the canvas.

We now use two memoization strategies for key selectors:

  1. Deep input comparison (createDeepEqualSelector) - Skip computation when inputs are structurally equal
  2. Deep result comparison (createResultEqualSelector) - Return cached reference when output is structurally equal

For small arrays of IDs (selectVisibleLayerIds, selectAllImageIds), the deep comparison cost is negligible. For larger vertex arrays, the comparison cost is still much lower than the downstream React/canvas re-render cost it prevents.

@bobnik bobnik changed the title Feature/selector optimizations Selector optimizations Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants