reactjs + materail-ui出错

时间:2018-01-16 23:47:14

标签: reactjs material-ui

我在构建一个简单的应用程序时收到此错误,该应用程序有两个路由,一个到'/',另一个到'/ search'。我使用了材料的各种组件-ui。

问题是当我路由到'/ search'时会抛出以下错误:

我已经尝试了所有必要的东西但却无法弄清楚出了什么问题? 我只是在这里发布一半代码:

  function capitalizeFirstLetter(string) {
  28 |   process.env.NODE_ENV !== "production" ? (0, _warning2.default)(typeof string === 'string', 'Material-UI: capitalizeFirstLetter(string) expects a string argument.') : void 0;
  29 | 
> 30 |   return string.charAt(0).toUpperCase() + string.slice(1);
  31 | } //  weak
  32 | 
  33 | function contains(obj, pred) {
View compiled
Typography
node_modules/material-ui/Typography/Typography.js:114
  111 |     other = (0, _objectWithoutProperties3.default)(props, ['align', 'classes', 'className', 'component', 'color', 'gutterBottom', 'headlineMapping', 'noWrap', 'paragraph', 'type']);
  112 | 
  113 | 
> 114 | var className = (0, _classnames2.default)(classes.root, classes[type], (_classNames = {}, (0, _defineProperty3.default)(_classNames, classes['color' + (0, _helpers.capitalizeFirstLetter)(color)], color !== 'default'), (0, _defineProperty3.default)(_classNames, classes.noWrap, noWrap), (0, _defineProperty3.default)(_classNames, classes.gutterBottom, gutterBottom), (0, _defineProperty3.default)(_classNames, classes.paragraph, paragraph), (0, _defineProperty3.default)(_classNames, classes['align' + (0, _helpers.capitalizeFirstLetter)(align)], align !== 'inherit'), _classNames), classNameProp);
  115 | 
  116 | var Component = componentProp || (paragraph ? 'p' : headlineMapping[type]) || 'span';
  117 | 
View compiled
mountIndeterminateComponent
node_modules/react-dom/cjs/react-dom.development.js:8032
  8029 |     warning(false, "The <%s /> component appears to have a render method, but doesn't extend React.Component. " + 'This is likely to cause errors. Change %s to extend React.Component instead.', componentName, componentName);
  8030 |   }
  8031 |   ReactCurrentOwner.current = workInProgress;
> 8032 |   value = fn(props, context);
  8033 | }
  8034 | // React DevTools reads this flag.
  8035 | workInProgress.effectTag |= PerformedWork;
View compiled
beginWork
node_modules/react-dom/cjs/react-dom.development.js:8221
  8218 | 
  8219 | switch (workInProgress.tag) {
  8220 |   case IndeterminateComponent:
> 8221 |     return mountIndeterminateComponent(current, workInProgress, renderExpirationTime);
  8222 |   case FunctionalComponent:
  8223 |     return updateFunctionalComponent(current, workInProgress);

1 个答案:

答案 0 :(得分:0)

我在Typography.js中看到它使用capitalizeFirstLetter作为颜色并对齐。 检查你是否插入了不是字符串的东西。