反应导入模式不起作用(来自语义-ui-反应)

React import modal not working (from semantic-ui-react)

我正在尝试将语义 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 文件夹与我的包中的 Dropdown 处于同一级别。 欢迎任何帮助!

谢谢

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

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

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

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

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

希望对您有所帮助