支持`children`在`AppBar`中被标记为必需,但它的值是'undefined`

Ale*_*rov 7 reactjs material-ui

我想使用本机Material-ui组件,但在浏览器中出现此错误:

index.js:2178警告:支柱类型失败:支柱children标记为必需AppBar,但其值为undefined.

我的组件是:

import React from 'react';
import AppBar from 'material-ui/AppBar';

/**
 * A simple example of `AppBar` with an icon on the right.
 * By default, the left icon is a navigation-menu.
 */
const Header = () => (
  <AppBar
    title="Title"
    iconClassNameRight="muidocs-icon-navigation-expand-more"
  />
);

export default Header;
Run Code Online (Sandbox Code Playgroud)

帮帮我理解为什么?

小智 0

子组件是您的主要组件所包含的组件,因此它应该是:

<AppBar
  title="Title"
  iconClassNameRight="muidocs-icon-navigation-expand-more"
>
  <ChildrenComponent />
</AppBar>
Run Code Online (Sandbox Code Playgroud)

如果不需要孩子的话,就不用按要求放。