-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
task/WG-432 rework hooks, maps and feature tree to minimize renders #339
base: main
Are you sure you want to change the base?
task/WG-432 rework hooks, maps and feature tree to minimize renders #339
Conversation
…hanges-filter-changes
…hanges-filter-changes
…hanges-filter-changes
…hanges-filter-changes
Moving functions out of the render cycle and into memoized component properties. Changes account for feature selection time from 700ms to 20ms
Prevent unnecessary re-renders by removing searchParams dependency as selectedFeatureId is enough. Also useMemo for selectedFeatureId determination
Ensure that setSelectedFeatureID is not dependent on selectedFeatureId
Make some optimizations in Map and FeatureFileTree
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.
LGTM
const { height, ref } = useResizeDetector(); | ||
const { height: rawHeight, ref } = useResizeDetector({ | ||
refreshMode: 'debounce', | ||
refreshRate: 50, // Small debounce to avoid initial extreme values seen on comonent remount |
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.
refreshRate: 50, // Small debounce to avoid initial extreme values seen on comonent remount | |
refreshRate: 50, // Small debounce to avoid initial extreme values seen on component remount |
const prevDataRef = useRef<FeatureCollection | undefined>(undefined); | ||
const prevStateRef = useRef<{ pending: boolean; error: boolean }>({ | ||
pending: false, | ||
error: false, | ||
}); |
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.
Just curious, I wonder if react query's keepPreviousData
could be of use here?
Overview:
This PR reworked hooks, maps and feature tree to minimize renders and optimize things.
The main issues we noticed were:
The fixes were:
useCurrentFeatures
hook so that provides stable reference to the latest featuresuseFeatureSelection
hook to ensure that setSelectedFeatureID is not dependent on selectedFeatureIdOff-topic change:
PR Status:
Related Jira tickets:
Summary of Changes:
Testing Steps:
Notes:
TODO