Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: Cannot read properties of null (reading 'scrollTop') Material UI

I have migrated MUI-4 to MUI-5 and facing this error. Any Help?

like image 227
Muhammad Wasim Akram Avatar asked Mar 04 '26 04:03

Muhammad Wasim Akram


1 Answers

I discovered that I was feeding my own component inside the SnackBar. When I wrapped the content of SnackBar in a div, it was fixed. As the error message says "Expected an element that can hold a ref," SnackBar's child needs to be an element that can hold a ref, e.g. a div.

Before: <SnackBar> <MyAlert/> </SnackBar>

After: <SnackBar><div> <MyAlert/> </div> </SnackBar>

Thanks

like image 191
Muhammad Wasim Akram Avatar answered Mar 05 '26 17:03

Muhammad Wasim Akram



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!