Material-ui: Menu Component throws Error, I believe in conjunction with the popover element.

Created on 2 Sep 2020  路  7Comments  路  Source: mui-org/material-ui

Copying the code straight to the react project from the material-ui documentation,
https://codesandbox.io/s/sm1zv?file=/demo.js
the following error appears;

Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of Transition which is inside StrictMode. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://fb.me/react-strict-mode-find-node
    in div (created by ForwardRef(Paper))
    in ForwardRef(Paper) (created by WithStyles(ForwardRef(Paper)))
    in WithStyles(ForwardRef(Paper)) (created by Transition)
    in Transition (created by ForwardRef(Grow))
    in ForwardRef(Grow) (created by Unstable_TrapFocus)
    in Unstable_TrapFocus (created by ForwardRef(Modal))
    in div (created by ForwardRef(Modal))
    in ForwardRef(Portal) (created by ForwardRef(Modal))
    in ForwardRef(Modal) (created by ForwardRef(Popover))
    in ForwardRef(Popover) (created by WithStyles(ForwardRef(Popover)))
    in WithStyles(ForwardRef(Popover)) (created by ForwardRef(Menu))
    in ForwardRef(Menu) (created by WithStyles(ForwardRef(Menu)))

package.json

"@material-ui/core": "^4.11.0",
    "@material-ui/icons": "^4.9.1",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-router-dom": "^5.2.0",
    "react-scripts": "3.4.3"
question

All 7 comments

Solved in v5-alpha.

The exact example as in the provided sandbox does not throw the error. You have to wrap the app in React.StrictMode element.

Also happens with Dialog component with the example on the demo page https://material-ui.com/components/dialogs/#alerts

Hmm, wrapping my app in strict mode did not seem to do it. I am still getting the error for the elements Popper and SpeedDial. :( Both seem to function fine, its just sad to see the error. Also, I have not had that error appear in a dialog component before.

Wrapping your app with React.StrictMode element should produce the error, as it is doing extra checks that detect the error. Removing the React.StrictMode wrapping should "hide" the error.

That did it. Thanks for the help :)

just installed and first thing I tired got this bug. Push the fix.

@sgehrman, Is this fix, or can this fix, be made available in 4.x?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

activatedgeek picture activatedgeek  路  3Comments

anthony-dandrea picture anthony-dandrea  路  3Comments

finaiized picture finaiized  路  3Comments

revskill10 picture revskill10  路  3Comments

pola88 picture pola88  路  3Comments