代码之家  ›  专栏  ›  技术社区  ›  John Livermore

简单反应组件的无效元素类型错误

  •  0
  • John Livermore  · 技术社区  · 6 年前

    下面的简单react代码有一个错误。

    import React, { Component } from 'react';
    import { Panel } from 'react-bootstrap';
    
    export class NewFloodRequest extends Component {
        render() {
            return (
                <Panel>
                    <Panel.Body>Panel content</Panel.Body>
                    <Panel.Footer>Panel footer</Panel.Footer>
                </Panel>
            );
        }
    }
    

    元素类型无效:应为字符串(对于内置组件) 或类/函数(用于复合组件),但得到:未定义。你 可能忘了从文件中导出组件, 或者您可能混淆了默认导入和命名导入。

    检查的渲染方法 NewFloodRequest .

    有人能看看这里有什么问题吗?

    enter image description here

    更新 根据@riwu下面的建议,我通过package.json更改了react引导版本,并修复了问题。

      "dependencies": {
    ...
        "react-bootstrap": "^0.32.1",
    ...
      },
    
    1 回复  |  直到 6 年前
        1
  •  3
  •   Roy Wang    6 年前

    你需要升级 react-bootstrap 0.32.1 为了新的 Panel 应用程序编程接口。

    Edit 71l2wzllwq