Material-ui: Cannot convert undefined or null to object

Created on 3 Dec 2018  ยท  19Comments  ยท  Source: mui-org/material-ui

After a migration to the 3.6.1 version and when I open a Modal. I have the following error:

errorlog

data.style is undefined

error

I think wee need to check if data.style exists or not (?)

  • [x] This is not a v0.x issue.
  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Your Environment ๐ŸŒŽ

| Tech | Version |
|--------------|---------|
| Material-UI | v3.6.1 |
| React | 16.6.3 |
| Browser | |
| TypeScript | |
| etc. | |

bug ๐Ÿ› Dialog

All 19 comments

related to #13733

It looks like a regression. Can somebody provide a reproduction? It would help, a lot. Thank you!

I faced this error once - right after updated the lib to 3.6.1
But then I've tried to reproduce it for @oliviertassinari in codesandbox and everything worked fine
also it disappeared from my project after I cleaned modules cache and rm -rf node_modules; yarn install

โžœ โœ— npm ls @material-ui/core version                                                                                                                                                                       
[email protected] /path
โ””โ”€โ”€ @material-ui/[email protected]

it's rather a human factor than an issue with the lib
cannot reproduce

we can reproduce it with this test. just add an unsupported property to the Modal component.
React raise this warning : Warning: React does not recognize theunsupportedPropprop on a DOM element.... . This warning causes this error after unmounting the Modal component.

const wrapper = mount(
   <Modal open={false} unsupportedProp="unsupported">
     <div />
   </Modal>,
 );
wrapper.setProps({ open: true });
wrapper.unmount();

This React warning shouldn't raise this error...

@amensouissi
See https://material-ui.com/api/modal/#props below the props table:

Any other properties supplied will be spread to the root element (native element).

It's a common pattern in material-ui components that additional props are spread to a documented child component. In this case it's a DOM node and the warning therefore correct.

@eps1lon
yes the warning is correct. but it must not cause the described error.

@eps1lon
yes the warning is correct. but it must not cause the described error.

Agreed. However I experienced the same issue that react warnings would cascade into enzyme and cause all sorts of other warnings (unrelated to the Modal). Not sure what enzyme is doing when react warnings are triggered. So be sure to fix the react warnings first so that we can isolate the issue. As it looks right now it might be an enzyme only issue.

finally I checked the props. The list of props is correct.
In summary:
1) I have a mounted Dialog component
2) then, url redirection with react-router => new url
3) redirect to a component with a Dialog with open === true
4) then an error equivalent to the error with unsupported props

errorlog

 <Dialog
        hideBackdrop={...}
        PaperProps={...}
        classes={{
          root: ...,
          paper: ...
        }}
        onEntered={...}
        fullScreen={...}
        open={...}
        onExited={...}
        TransitionComponent={...}
      >...</Dialog>

I think the error is related to the react-router redirection.

  1. then an error equivalent to the error with unsupported props

That error message should give you a hint what's wrong. Could you add it in case someone else has the same issue?

message edited

Alright, I have found a simple reproduction.

@amensouissi I'm updating your pull request with the failing test case.

How to fix this issue?

@pavanshinde47

13778

I am sorry, but I am not sure what the solutions is? Is it to update the version to 3.6.1? If so i already did it but still facing the issue. Kindly let me know the exact solution. Thanks.

@pavanshinde47 Rollback to a previous version.

@pavanshinde47 Rollback to a previous version.

previous was 3.2.0, the issue started here so i updated to 3.6.1.

Hi, confused by the last two comments.

Is this fixed on version 3.6.1?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

finaiized picture finaiized  ยท  3Comments

revskill10 picture revskill10  ยท  3Comments

anthony-dandrea picture anthony-dandrea  ยท  3Comments

ghost picture ghost  ยท  3Comments

ghost picture ghost  ยท  3Comments