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.
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
Component refactor: migrate PopoverWithMeasuredContent to function component #22868
Component refactor: migrate PopoverWithMeasuredContent to function component #22868
Changes from 1 commit
cc61881
b91913b
320dc97
bd39164
ad0056b
66662bf
677d6ba
76c9d9d
1060bd3
8cc0916
21ac9f6
c8b6e74
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
This logic is not correct. Previously this was used with the window dimensions props.
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.
@s77rt This is not a replace. We change withWindowDimensions to useWindowDimensions hook so hoc is not needed anymore. And we had a
shouldComponentUpdate
hereApp/src/components/PopoverWithMeasuredContent.js
Lines 97 to 105 in e2e4057
React.memo
with props comparing function.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.
What I meant is the comparison logic is not correct.
prevProps.isVisible && !_.isEqual(prevProps, nextProps)
this makes no sense and it seems to be the cause of a regression, the floating action button is broken.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.
I think I'd better return windowWidth/Height props to handle this update logic - if isVisible update only on dimensions change.
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.
Let's use the hook and for the
React.memo()
we can omit the function parameters. The "do not update if only window dimensions change" is useless, the component will pretty much already re-render because we are passing a lot of changing data (e.g. anchorPosition is always a new object).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.
No, this leads to a regression with browser window dimensions change. I'll fix the logic
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.
Interesting bug. We should fix that bug instead of hiding it. Any ideas yet on the root cause?
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.
@s77rt I think the root cause is that shiftedAnchorPosition left/top could be <0 on some updates. You could see it if you add console.log right before return and leave React.memo without props comparing function. So it seems to be not hiding the bug but prevent unnecessary updates.
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.
@alexxxwork This still does not explain the root cause. Something is not right, the whole content changes.