question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[transitions] "Cannot read property `scrollTop` of null"

See original GitHub issue
  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

If the child of <Transition> components does not forwardRef to DOM, it cause this error.

Screen Shot 2564-07-07 at 09 24 14

Expected Behavior 🤔

The error should be more informative about how to fix it.

Steps to Reproduce 🕹

Steps:

  1. open this sandbox https://codesandbox.io/s/transition-v5-error-dide8?file=/src/App.tsx
  2. change material-ui/core to v5.beta
  3. will see the error

Context 🔦

Is it better to display warning (in console) instead of Error?

Here is what I think about the dev experience.

  • write the code (use Transition the wrong way, no forwardRef for child)
  • check in browser, it does not work (the ui display without transitioning)

then, 3 possibilities

  • they see the warning in console about why it does not work and link to full doc example
  • they go to Transition docs
  • worse case, they open the issue

Actions

Your Environment 🌎

`npx @material-ui/envinfo`
  Don't forget to mention which browser you used.
  Output from `npx @material-ui/envinfo` goes here.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:12
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

10reactions
totszwaicommented, May 4, 2022

Also facing the same problem… so are you saying that if the child is a styled-component and does not have a forwardRef it would not work…? Shouldn’t the Fade (or all transitions) work with or without a ref?

We have many components that are just plain styled-components without a ref (because there were simply no need to use a ref) but now we have to add it everywhere just to get transition to work??

Perhaps all transitions should wraps the child with a plain div instead?

The workaround I had to do, was to manually wrap the children with another div… 👎

      <Fade in={visible} timeout={1000}>
        <div>{children}</div>
      </Fade>
6reactions
thovdencommented, Jul 14, 2021

Thanks - this saved me some debugging. I had this construct:

<Zoom in timeout={200}>
  <React.Fragment>

Fixed by adding the actual components as the only child, e.g.,

<Zoom in timeout={200}>
  <Fab>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Testing Material Ui (v5) Drawer - Cannot read property ...
Workaround - Apply the following props on Drawer or any Modal based component (eg. Dialog ) to disable Transitions whilst running tests. const ......
Read more >
Cannot read property 'scrollTop' of null - Bountysource
There seems to be some issue while using the dropzone in function components. Most probably with the snackbar thingy as the file seems...
Read more >
Troubleshooting - Material UI - MUI
Cannot read property scrollTop of null. This error comes from Fade , Grow , Slide , Zoom components due to a missing DOM...
Read more >
When editing a user picker custom field, a 'Cannot read ...
Exception: Uncaught TypeError: Cannot read property 'scrollTop' of undefined. Steps to reproduce. Create a customfield with User Picker (multiple users) ...
Read more >
HTML DOM Element scrollTop Property - W3Schools
The number of pixels the element's content is scrolled vertically. If the number is negative, the number is set to 0. If the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found