提供给`ForwardRef(ListItemIcon)`的`array`类型的无效prop`children`,需要一个ReactElement

时间:2019-05-28 11:38:08

标签: reactjs material-ui

<ListItemIcon>下,我想使用豆芽图像作为图标。我正在进入CSS类。因此我正在收到此警告。

<ListItemIcon key={subOption.text+i+'h'}><span key={i+subOption.text+'i'} className={`${subOption.icon} ${classes.submenuPosition}`}/> </ListItemIcon>

<ListItem  button key={i+subOption.text+'g'} onClick={ () => this.handleClick( subOption.text ) }>
                <ListItemIcon key={subOption.text+i+'h'}><span key={i+subOption.text+'i'} className={`${subOption.icon} ${classes.submenuPosition}`}/> </ListItemIcon>
                <ListItemText inset style={{marginBottom:'-5px',marginTop:'-8px', padding:'0px 16px',marginLeft:'9px'}} primary={ subOption.text }  key={subOption.text+'j'+i}
                className="menu-text-Color"
                />
                    { 
                      state[ subOption.text ] ? <ExpandLess key={i+"im"} style={{"marginTop": "-19px","marginRight": "-15px"}} /> : <ExpandMore key={i+"i"} style={{"marginTop": "-19px","marginRight": "-15px"}}/>
                    }
              </ListItem>

遇到此错误。

  

警告:道具类型失败:children类型的道具array无效   提供给ForwardRef(ListItemIcon),期望一个   ReactElement。       在ForwardRef(ListItemIcon)中(由WithStyles(ForwardRef(ListItemIcon)创建))       在WithStyles(ForwardRef(ListItemIcon))中(在menu.js:216处)       在div中(由ForwardRef(ButtonBase)创建)       在ForwardRef(ButtonBase)中(由WithStyles(ForwardRef(ButtonBase)创建))       在WithStyles(ForwardRef(ButtonBase))中(由ForwardRef(ListItem)创建)       在ForwardRef(ListItem)中(由WithStyles(ForwardRef(ListItem)创建))       在WithStyles(ForwardRef(ListItem))中(在menu.js:215处)       在ul中(由ForwardRef(List)创建)       在ForwardRef(List)中(由WithStyles(ForwardRef(List)创建))       在WithStyles(ForwardRef(List))中(在menu.js:214处)       在div中(由ForwardRef(Paper)创建)       在ForwardRef(Paper)中(由WithStyles(ForwardRef(Paper)创建))       在WithStyles(ForwardRef(Paper))中(由ForwardRef(Drawer)创建)       在div中(由ForwardRef(Drawer)创建)       在ForwardRef(Drawer)中(由WithStyles(ForwardRef(Drawer)创建))       在WithStyles(ForwardRef(Drawer))中(由WithStyles(WithStyles(ForwardRef(Drawer)))创建)       在WithStyles(WithStyles(ForwardRef(Drawer)))中(在menu.js:266)       在ClickAwayListener中(在menu.js:265)       在Menu中(由WithStyles(Menu)创建)       在WithStyles(Menu)(在Home.js:130)中       在标题中(由ForwardRef(Paper)创建)       在ForwardRef(Paper)中(由WithStyles(ForwardRef(Paper)创建))       在WithStyles(ForwardRef(Paper))中(由ForwardRef(AppBar)创建)       在ForwardRef(AppBar)中(由WithStyles(ForwardRef(AppBar)创建))       在WithStyles(ForwardRef(AppBar))中(位于Home.js:123)       在路由器中(由HashRouter创建)       在HashRouter中(在Home.js:122)       在div中(在Home.js:118上)       在家庭中(由WithStyles(Home)创建)       在WithStyles(Home)中(在App.js:19)       在_class中(由Context.Consumer创建)       在路线中(在App.js:47)       在Switch中(在App.js:44)       在路由器中(由BrowserRouter创建)       在BrowserRouter中(在App.js:43)       在App中(位于src / index.js:7)

0 个答案:

没有答案
相关问题