如何解决此错误无法读取t.isMuiElement处未定义的属性“ muiName”?

时间:2018-11-23 11:32:22

标签: reactjs dialog material-ui

在Chrome浏览器中出现此问题。

Uncaught TypeError: Cannot read property 'muiName' of undefined at t.isMuiElement (reactHelpers.js:31) 

当我在<List> <ListItem>中使用<DialogContent>时,将显示错误。

         <DialogContent> 
              <List>
                  <ListItem> <ListItemText primary='Minimum booking notice: 24 hours in advance' /> </ListItem>            
                <ListItem> <ListItemText primary='Tour costs: Tour costs and what inclusion or exclusion is listed on the itinerary for each tour. No refunds will be given for unutilized services.'/></ListItem>
              </List>
          </DialogContent>

解决方案是什么?

谢谢大家。

1 个答案:

答案 0 :(得分:1)

我意识到要使用muiName

What is the muiName property and when do I have to set it for Material-UI components?

const DialogContentList = (props) => (
  <List>
  <ListItem> 
    <ListItemText primary='Minimum booking notice: 24 hours in advance' />
  </ListItem> 
  </List>
);
DialogContentList.muiName = 'IconMenu';
class Footer extends Component {
      constructor(props) {
        super(props);
        this.state= {
          open: false
        }     
      }
      render() {
<DialogContentList />
      }
    }
    export default withMobileDialog()(withStyles(styles)(Footer));

我找到了问题的原因。过去,我使用的是{strong>已弃用的material-ui 。因此,使用material-ui/core/代替了。 在我使用

之前

import List, { ListItem, ListItemText } from '@material-ui/core/List'; 现在我用这个

import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem'; 
import ListItemText from '@material-ui/core/ListItemText'; 

我的问题已解决