-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
docs: update popover custom target story #31374
Merged
Merged
Conversation
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
Previously the example relied on React refs as dependencies to a useEffect() call but these will never trigger the effect. The example still works but when trying to extrapolate from it and target elements that appear after the first render, the example breaks down because the effect will not be triggered. This example takes advantage of the fact that useMergedRefs() supports functions as refs so we can trigger the effect when the refs are set. Using setState() was also considered but this will always trigger a re-render, negatively affecting performance so this pattern, while perhaps useful in some cases, is not a good example for best practices documentation. The useEffect() could have its dependencies removed so it would be called every render which should allow it to function as needed with less of a performance overhead than the setState() approach.
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
Perf Analysis (
|
Scenario | Render type | Master Ticks | PR Ticks | Iterations | Status |
---|---|---|---|---|---|
Avatar | mount | 617 | 646 | 5000 | |
Button | mount | 310 | 314 | 5000 | |
Field | mount | 1119 | 1097 | 5000 | |
FluentProvider | mount | 715 | 714 | 5000 | |
FluentProviderWithTheme | mount | 78 | 82 | 10 | |
FluentProviderWithTheme | virtual-rerender | 36 | 33 | 10 | |
FluentProviderWithTheme | virtual-rerender-with-unmount | 76 | 71 | 10 | |
MakeStyles | mount | 864 | 862 | 50000 | |
Persona | mount | 1730 | 1659 | 5000 | |
SpinButton | mount | 1384 | 1370 | 5000 | |
SwatchPicker | mount | 1510 | 1527 | 5000 |
📊 Bundle size report✅ No changes found |
packages/react-components/react-popover/stories/Popover/PopoverAnchorToCustomTarget.stories.tsx
Outdated
Show resolved
Hide resolved
packages/react-components/react-popover/stories/Popover/PopoverAnchorToCustomTarget.stories.tsx
Outdated
Show resolved
Hide resolved
layershifter
approved these changes
May 16, 2024
spmonahan
commented
May 16, 2024
packages/react-components/react-popover/stories/Popover/PopoverAnchorToCustomTarget.stories.tsx
Outdated
Show resolved
Hide resolved
🕵 fluentuiv9 No visual regressions between this PR and main |
miroslavstastny
pushed a commit
to miroslavstastny/fluentui
that referenced
this pull request
Jun 14, 2024
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.
Previous Behavior
Previously the example relied on React refs as dependencies to a
useEffect()
call but these will never trigger the effect. The example still works but when trying to extrapolate from it and target elements that appear after the first render, the example breaks down because the effect will not be triggered.New Behavior
This example takes advantage of the fact that useMergedRefs() supports functions as refs so we can trigger the effect when the refs are set.
Using
setState()
was also considered but this will always trigger a re-render, negatively affecting performance so this pattern, while perhaps useful in some cases, is not a good example for best practices documentation.setState()
is the approach demonstrated in the positioning docs (link)The
useEffect()
could have its dependencies removed so it would be called every render which should allow it to function as needed with less of a performance overhead than thesetState()
approach. This may be a better approach for documentation.Related Issue(s)
This PR is motivated by user feedback.