【问题标题】:React import modal not working (from semantic-ui-react)React 导入模式不起作用(来自语义 UI 反应)
【发布时间】:2019-01-14 18:15:39
【问题描述】:

我正在尝试将语义 UI 用于 React 及其模态。

下拉是好的,但无法加载模式:

import {DropDown} from "semantic-ui-react";
import {Modal} from "semantic-ui-react";

export default class Builder extends Component {  
  render(){
  return(

   <DropDown/>
   <Modal/>
)
}
}

控制台返回此错误:

app.js:547 Warning: React.createElement: type is invalid -- expected a string 
(for built-in components) or a class/function (for composite components) but got: undefined
You likely forgot to export your component from the file it's defined in. 
Check the render method of `Portal`.

我已经尝试过这样的:

import Modal from "semantic-ui-react";

正如我所见,Modal 文件夹与我的包中的下拉菜单处于同一级别。 欢迎任何帮助!

谢谢

【问题讨论】:

    标签: reactjs semantic-ui semantic-ui-react


    【解决方案1】:

    我认为您的问题的解决方案是以下之一:

    1. 您忘记导入import React, { Component } from "react";

    2. 代码的结构。您必须将两个 JSX 元素包装在一个封闭标记中,因为它们是相邻的。应该是这样的:

      <div> <Dropdown/> <Modal/> </div>

    3. 您不必分开导入两个组件,因为它们都在 semantic-ui-react 库中。

    希望对你有帮助

    【讨论】:

    • 感谢您的回答。我按照你说的做了,并将我的 React 更新到了最新版本,现在一切正常!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-09
    • 2018-12-07
    • 2019-12-26
    相关资源
    最近更新 更多