-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Components: refactorFocalPointPicker
to pass exhaustive-deps
#41520
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b7c7d96
FocalPointPicker: add `pan` to `useEffect` dep array
chad1008 ac030fc
refactor `useRef` calls for both `locationPageOffset` variables
chad1008 8eacfe4
add `pan`, `onChange`, and `shouldEnableBottomSheetScroll` to `panRes…
chad1008 c9ffb72
FocalPointPicker: add `startAnimation` to `useEffect` dep array. Wrap…
chad1008 2078780
FocalPointPicker: update changelog
chad1008 b89fbb2
move `startAnimation` directly into `useEffect`
chad1008 63cd003
FocalPointPicker: wrap `FocalPointSettingsPanelMemo`s `onChange` in a…
chad1008 d73ee30
FocalPointPicker: fix typo to ensure `setPosition` is actually invoked
chad1008 3ebaf4a
Update packages/components/src/mobile/focal-point-settings-panel/inde…
chad1008 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
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.
It looks like
onChange
is changing on every change that's happening on the Focal point picker when updating the sliders and during the touch events, making thepanResponder
to be created constantly.This prop is coming from here. So I think we should add a
useCallback
there (forsetPosition
) to prevent this from happening.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.
Thanks @geriux! Let me know if e963825 helps improve things! 😄
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.
Actually scratch that. There's a typo in this commit that was preventing the linter from detecting further issues. Stand by! 😬
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.
Okay, fixed again in 86ba326.
One odd wrinkle is that
exhaustive-deps
doesn't seem to mind the empty dep array, when I'd have expected it to want us to addsetPosition
as a dependency. If we do add it, we get a warning from the linter (unsurprisingly) that it's changing on every render.I'm thinking it might be that the linter can detect that
setPosition
just callssetDraftFocalPoint
, which in turn comes fromuseState
and will therefor never change. My understanding is that ESLint is smart enough not to require state-setters as deps, but I didn't realize it could parse through an additional layer of abstraction like this (assuming I'm understanding things correctly here).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.
@geriux good catch! How did you come across the changing
onChange
value? Did you notice a performance issue or observe it in a different manner? Primarily curious to improve my ability to identify this type of thing in the future.