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.

material-ui's Modal.js throwing out error with Preact

See original GitHub issue

Iam using material-ui for my Reactjs application. When I use Preact-compat as alias for “react” I get below error

Uncaught TypeError: Cannot read property 'hasOwnProperty' of undefined
    at getHasTransition (Modal.js?a179:62)
    at Function.getDerivedStateFromProps (Modal.js?a179:391)
    at renderComponent (preact.mjs?c80d:500)
    at renderComponent (preact.mjs?c80d:550)
    at renderComponent (preact.mjs?c80d:550)
    at renderComponent (preact.mjs?c80d:550)
    at renderComponent (preact.mjs?c80d:550)
    at renderComponent (preact.mjs?c80d:550)
    at setComponentProps (preact.mjs?c80d:471)
    at buildComponentFromVNode (preact.mjs?c80d:637)

What could be the possible issue?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
developitcommented, Feb 3, 2019

Update: this is just silly use of props.children, they’re assuming it’s the only child. Material-UI should be using Children.only():

https://github.com/mui-org/material-ui/blob/next/packages/material-ui/src/Modal/Modal.js#L22

1reaction
marvinhagemeistercommented, Mar 8, 2019

@eps1lon The console.log only works because props.children defaults to being an array in Preact 8.x . So effectively the snippet does this [].props which is undefined because an array has no props property. The issue is that this [].props.hasOwnProperty("foo") will throw which seems to be the issue the original poster is experiencing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error Handling - Preact
To test our error handling knowledge, let's add error handling to a simple App component. One of the components deep within App can...
Read more >
Modal react component in material-ui app throwing error
It's my first time working on a React App, and I'm struggling with this error:
Read more >
@material-ui/core | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
Error when rendering React Portal with Storyshots-Reactjs
Fetching array of array in react js from JSON response · Hyperstack and MaterialUI Drawer Toggling State is causing the drawer to open...
Read more >
material-ui/core/CHANGELOG.md - UNPKG
The development of v4 is limited to important bug fixes, security patches and easing the ... 1186, - [Modal] Fix zoom out on...
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