[ButtonBase] Cannot read properties of null (reading 'pulsate') React v18
See original GitHub issueDuplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Current behavior 😯
Applying the autoFocus
prop to a Button
component throws an error. This happens when using React v18, everything works as expected in React v17.
Uncaught TypeError: Cannot read properties of null (reading 'pulsate')
at ButtonBase.js:147:25
at commitHookEffectListMount (react-dom.development.js:22912:26)
at commitPassiveMountOnFiber (react-dom.development.js:24642:13)
at commitPassiveMountEffects_complete (react-dom.development.js:24606:9)
at commitPassiveMountEffects_begin (react-dom.development.js:24593:7)
at commitPassiveMountEffects (react-dom.development.js:24581:3)
at flushPassiveEffectsImpl (react-dom.development.js:26700:3)
at flushPassiveEffects (react-dom.development.js:26653:14)
at commitRootImpl (react-dom.development.js:26604:5)
at commitRoot (react-dom.development.js:26380:5)
I found two old issues with the same error (link | link), but they do not seem to be related.
Expected behavior 🤔
The component should not throw an error.
Steps to reproduce 🕹
Steps:
- Use React v18
- Apply the
autoFocus
prop to aButton
component - 💥
- StackBlitz with Vite & React v18 (remove
autoFocus
and reload to see the Button displayed as expected) - StackBlitz with Vite & React v17
I have reproduced this locally in Chrome v97. I have also reproduced this locally with a Webpack-based build.
Context 🔦
No response
Your environment 🌎
`npx @mui/envinfo`
System:
OS: Linux undefined
Binaries:
Node: 14.16.0 - /usr/local/bin/node
Yarn: 1.22.10 - /bin/yarn
npm: 7.17.0 - /bin/npm
Browsers:
Chrome: Not Found
Firefox: Not Found
npmPackages:
@emotion/react: ^11.7.1 => 11.7.1
@emotion/styled: ^11.6.0 => 11.6.0
@mui/base: 5.0.0-alpha.67
@mui/material: ^5.4.0 => 5.4.0
@mui/private-theming: 5.3.0
@mui/styled-engine: 5.3.0
@mui/system: 5.4.0
@mui/types: 7.1.0
@mui/utils: 5.3.0
@types/react: 17.0.39
react: 18.0.0-rc.0 => 18.0.0-rc.0
react-dom: 18.0.0-rc.0 => 18.0.0-rc.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Cannot read properties of null (reading 'pulsate') in material-ui ...
I tried removing each prop in button and checked whether it is working or not. I found, button works without autoFocus prop.
Read more >Cannot read properties of null (reading 'pulsate') in material-ui ...
Coding example for the question Cannot read properties of null (reading 'pulsate') in material-ui Button component-Reactjs.
Read more >cannot read properties of null (reading '0') react - You.com
Applying the autoFocus prop to a Button component throws an error. This happens when using React v18, everything works as expected in React...
Read more >Design Patterns with React Easy State | by Bertalan Miklos
State management and beers. Easy State doesn't care about how you manage your state, it looks out for any kind of state mutations...
Read more >ButtonBase API - Material UI - MUI
Name Type Default
action ref
centerRipple bool false
children node
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is really an issue when upgrading to React 18, and moving to MUI v5 is not an option right now for an autoFocus problem.
This is another way to reproduce the issue and is not related to explicitly adding the
autoFocus
attribute, when a Button is part of a form and the user hits enter, the same pulstate error appears.For those like me who’re still stuck on v4, you still can use refs (And keepmounted if the problem occurs in a Dialog)