Add realm properties hooks and reduce main window re-renders.#5858
Draft
michelinewu wants to merge 10 commits into
Draft
Add realm properties hooks and reduce main window re-renders.#5858michelinewu wants to merge 10 commits into
michelinewu wants to merge 10 commits into
Conversation
BundleMonFiles added (4)
Total files change +12.54MB Final result: ✅ View report in BundleMon website ➡️ |
wesrupert
approved these changes
Apr 23, 2026
wesrupert
left a comment
Contributor
There was a problem hiding this comment.
LGTM, with two small suggestions
Comment on lines
+38
to
+42
| const { currentStep, currentIndex, showOnboarding } = useRealmProperties({ | ||
| currentStep: prop(OnboardingV2Service.state, 'currentStep'), | ||
| currentIndex: prop(OnboardingV2Service.state, 'currentIndex'), | ||
| showOnboarding: prop(OnboardingV2Service.state, 'showOnboarding'), | ||
| }); |
Contributor
There was a problem hiding this comment.
Out of curiousity, is there a benefit to this approach vs the useRealmObjectProperties multi-key signature? From my read of realm.ts changes, this would also be a valid call:
const { currentStep, currentIndex, showOnboarding } = useRealmObjectProperty(
OnboardingV2Service.state,
'currentStep',
'currentIndex',
'showOnboarding'
);Comment applies throughout, so I'll just leave it on this one.
| const { CustomizationService, EditorCommandsService, SourcesService, AudioService } = Services; | ||
|
|
||
| const performanceMode = useRealmObject(CustomizationService.state).performanceMode; | ||
| const { performanceMode } = useRealmObjectProperty(CustomizationService.state, 'performanceMode'); |
Contributor
There was a problem hiding this comment.
Nit, but throughout - this gets pretty verbose in some files, especially when renaming the tracked value. I'd recommend two changes:
- Rename
useRealmObjectProperty->useRealmProperty, to matchuseRealmProperties - If there is only one key (or just make this the "one key only" version, for simplicity/maintainability), return the value directly.
Together, this line would become:
const performanceMode = useRealmProperty(CustomizationService.state, 'performanceMode');The benefits are better realized in other files, like app/components-react/windows/Settings.tsx:
This:
const { currentSettingsTab: currentTab } = useRealmObjectProperty(
NavigationService.state,
'currentSettingsTab',
);Becomes this:
const currentTab = useRealmProperty(NavigationService.state, 'currentSettingsTab');
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Overview
This PR introduces new React hooks (useRealmProperty and useRealmProperties) to minimize unnecessary component re-renders across the application, particularly in the main window.
Issues Addressed
Solutions Implemented
New Hooks (app/components-react/hooks/realm.ts)
Component Refactoring
Bug Fixes