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

[Button][base] Prevent too many ref updates #33882

Merged
merged 7 commits into from Aug 29, 2022

Conversation

michaldudak
Copy link
Member

@michaldudak michaldudak commented Aug 10, 2022

The ref callback is useButton was not a stable reference and thus was called too often. It caused issues, as it sets the state inside.

This PR wraps it in useCallback, preventing the problem.

Fixes #33457

@michaldudak michaldudak added bug 🐛 Something doesn't work component: button This is the name of the generic UI component, not the React module! package: base-ui Specific to @mui/base labels Aug 10, 2022
@michaldudak michaldudak requested a review from a team August 10, 2022 12:56
@mui-bot
Copy link

mui-bot commented Aug 10, 2022

Details of bundle changes

Generated by 🚫 dangerJS against 269c6a1

@mnajdova mnajdova added the PR: needs test The pull request can't be merged label Aug 11, 2022
@michaldudak michaldudak force-pushed the iss/33457-useSelect-mobile-crash branch from fabfb0d to a110cd6 Compare August 17, 2022 14:06
@michaldudak
Copy link
Member Author

michaldudak commented Aug 29, 2022

@mnajdova The issue solved by this PR occurs only on mobile Chrome. I wasn't able to reproduce it in our unit tests.

@michaldudak michaldudak merged commit a0c5385 into mui:master Aug 29, 2022
@michaldudak michaldudak deleted the iss/33457-useSelect-mobile-crash branch August 29, 2022 15:57
daniel-rabe pushed a commit to daniel-rabe/material-ui that referenced this pull request Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: button This is the name of the generic UI component, not the React module! package: base-ui Specific to @mui/base PR: needs test The pull request can't be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SelectUnstyled] useSelect demo crashes on tablet/smartphone
4 participants