material-ui's Modal.js throwing out error with Preact
See original GitHub issueIam 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:
- Created 5 years ago
- Reactions:1
- Comments:10 (6 by maintainers)
Top 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 >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
Update: this is just silly use of
props.children
, they’re assuming it’s the only child. Material-UI should be usingChildren.only()
:https://github.com/mui-org/material-ui/blob/next/packages/material-ui/src/Modal/Modal.js#L22
@eps1lon The
console.log
only works becauseprops.children
defaults to being anarray
in Preact 8.x . So effectively the snippet does this[].props
which isundefined
because an array has noprops
property. The issue is that this[].props.hasOwnProperty("foo")
will throw which seems to be the issue the original poster is experiencing.