Skip to content
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

Add forwardRef to wrapped re-exported lazy components #3887

Merged
merged 2 commits into from Sep 1, 2023

Conversation

garrettjstevens
Copy link
Collaborator

I noticed I was getting console errors and strange behavior when using the MUI Tooltip on another MUI component. Specifically I was using Tooltip to wrap IconButton, but the tooltip wouldn't appear until after the button had been clicked on. Eventually I found this docs page: https://mui.com/material-ui/guides/composition/#caveat-with-refs

What I eventually figured out is that basically, when we wrap lazy components in Suspsense, we have to use React.forwardRef to pass any refs on to the wrapped component. This allows things like Tooltip to work as usual.

I also had to add some display names after adding forwardRef to satisfy the "react/display-name" lint rule.

@garrettjstevens garrettjstevens self-assigned this Aug 31, 2023
@github-actions github-actions bot added the needs label triage Needs a label to show in changelog (breaking, enhancement, bug, documentation, or internal) label Aug 31, 2023
@codecov
Copy link

codecov bot commented Aug 31, 2023

Codecov Report

Merging #3887 (8806a02) into main (48dfe18) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #3887      +/-   ##
==========================================
+ Coverage   64.42%   64.43%   +0.01%     
==========================================
  Files        1004     1004              
  Lines       29789    29798       +9     
  Branches     7143     7143              
==========================================
+ Hits        19191    19200       +9     
  Misses      10432    10432              
  Partials      166      166              
Files Changed Coverage Δ
packages/core/ReExports/modules.tsx 15.19% <100.00%> (+3.91%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@cmdcolin cmdcolin added bug Something isn't working and removed needs label triage Needs a label to show in changelog (breaking, enhancement, bug, documentation, or internal) labels Sep 1, 2023
@cmdcolin cmdcolin merged commit 922bed2 into main Sep 1, 2023
11 checks passed
@cmdcolin cmdcolin deleted the forwardref_lazy_export branch September 1, 2023 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants